parse.c (143959) | parse.c (144020) |
---|---|
1/*- 2 * Copyright (c) 1988, 1989, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 1989 by Berkeley Softworks 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Adam de Boor. --- 25 unchanged lines hidden (view full) --- 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)parse.c 8.3 (Berkeley) 3/19/94 39 */ 40 41#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1988, 1989, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (c) 1989 by Berkeley Softworks 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Adam de Boor. --- 25 unchanged lines hidden (view full) --- 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)parse.c 8.3 (Berkeley) 3/19/94 39 */ 40 41#include <sys/cdefs.h> |
42__FBSDID("$FreeBSD: head/usr.bin/make/parse.c 143959 2005-03-22 07:50:40Z harti $"); | 42__FBSDID("$FreeBSD: head/usr.bin/make/parse.c 144020 2005-03-23 12:56:15Z harti $"); |
43 44/*- 45 * parse.c -- 46 * Functions to parse a makefile. 47 * 48 * One function, Parse_Init, must be called before any functions 49 * in this module are used. After that, the function Parse_File is the 50 * main entry point and controls most of the other functions in this --- 75 unchanged lines hidden (view full) --- 126 * line in the first makefile */ 127 128IFile curFile; /* current makefile */ 129 130/* stack of IFiles generated by * #includes */ 131static Lst includes = Lst_Initializer(includes); 132 133/* list of directories for "..." includes */ | 43 44/*- 45 * parse.c -- 46 * Functions to parse a makefile. 47 * 48 * One function, Parse_Init, must be called before any functions 49 * in this module are used. After that, the function Parse_File is the 50 * main entry point and controls most of the other functions in this --- 75 unchanged lines hidden (view full) --- 126 * line in the first makefile */ 127 128IFile curFile; /* current makefile */ 129 130/* stack of IFiles generated by * #includes */ 131static Lst includes = Lst_Initializer(includes); 132 133/* list of directories for "..." includes */ |
134Lst parseIncPath = Lst_Initializer(parseIncPath); | 134struct Path parseIncPath = TAILQ_HEAD_INITIALIZER(parseIncPath); |
135 136/* list of directories for <...> includes */ | 135 136/* list of directories for <...> includes */ |
137Lst sysIncPath = Lst_Initializer(sysIncPath); | 137struct Path sysIncPath = TAILQ_HEAD_INITIALIZER(sysIncPath); |
138 139/*- 140 * specType contains the SPECial TYPE of the current target. It is 141 * Not if the target is unspecial. If it *is* special, however, the children 142 * are linked as children of the parent but not vice versa. This variable is 143 * set in ParseDoDependency 144 */ 145typedef enum { --- 632 unchanged lines hidden (view full) --- 778 break; 779 } 780 } else if (strncmp(line, ".PATH", 5) == 0) { 781 /* 782 * .PATH<suffix> has to be handled specially. 783 * Call on the suffix module to give us a path to 784 * modify. 785 */ | 138 139/*- 140 * specType contains the SPECial TYPE of the current target. It is 141 * Not if the target is unspecial. If it *is* special, however, the children 142 * are linked as children of the parent but not vice versa. This variable is 143 * set in ParseDoDependency 144 */ 145typedef enum { --- 632 unchanged lines hidden (view full) --- 778 break; 779 } 780 } else if (strncmp(line, ".PATH", 5) == 0) { 781 /* 782 * .PATH<suffix> has to be handled specially. 783 * Call on the suffix module to give us a path to 784 * modify. 785 */ |
786 Lst *path; | 786 struct Path *path; |
787 788 specType = ExPath; 789 path = Suff_GetPath(&line[5]); 790 if (path == NULL) { 791 Parse_Error(PARSE_FATAL, 792 "Suffix '%s' not defined (yet)", 793 &line[5]); 794 return; --- 12 unchanged lines hidden (view full) --- 807 808 if (Dir_HasWildcards(line)) { 809 /* 810 * Targets are to be sought only in the current directory, 811 * so create an empty path for the thing. Note we need to 812 * use Dir_Destroy in the destruction of the path as the 813 * Dir module could have added a directory to the path... 814 */ | 787 788 specType = ExPath; 789 path = Suff_GetPath(&line[5]); 790 if (path == NULL) { 791 Parse_Error(PARSE_FATAL, 792 "Suffix '%s' not defined (yet)", 793 &line[5]); 794 return; --- 12 unchanged lines hidden (view full) --- 807 808 if (Dir_HasWildcards(line)) { 809 /* 810 * Targets are to be sought only in the current directory, 811 * so create an empty path for the thing. Note we need to 812 * use Dir_Destroy in the destruction of the path as the 813 * Dir module could have added a directory to the path... 814 */ |
815 Lst emptyPath = Lst_Initializer(emptyPath); | 815 struct Path emptyPath = TAILQ_HEAD_INITIALIZER(emptyPath); |
816 | 816 |
817 Dir_Expand(line, &emptyPath, &curTargs); | 817 Path_Expand(line, &emptyPath, &curTargs); 818 Path_Clear(&emptyPath); |
818 | 819 |
819 Lst_Destroy(&emptyPath, Dir_Destroy); | |
820 } else { 821 /* 822 * No wildcards, but we want to avoid code duplication, 823 * so create a list with the word on it. 824 */ 825 Lst_AtEnd(&curTargs, line); 826 } 827 --- 108 unchanged lines hidden (view full) --- 936 case Ignore: 937 ignoreErrors = TRUE; 938 break; 939 case Silent: 940 beSilent = TRUE; 941 break; 942 case ExPath: 943 LST_FOREACH(ln, &paths) | 820 } else { 821 /* 822 * No wildcards, but we want to avoid code duplication, 823 * so create a list with the word on it. 824 */ 825 Lst_AtEnd(&curTargs, line); 826 } 827 --- 108 unchanged lines hidden (view full) --- 936 case Ignore: 937 ignoreErrors = TRUE; 938 break; 939 case Silent: 940 beSilent = TRUE; 941 break; 942 case ExPath: 943 LST_FOREACH(ln, &paths) |
944 Dir_ClearPath(Lst_Datum(ln)); | 944 Path_Clear(Lst_Datum(ln)); |
945 break; 946 case Posix: 947 Var_Set("%POSIX", "1003.2", VAR_GLOBAL); 948 break; 949 default: 950 break; 951 } 952 } else if (specType == MFlags) { --- 53 unchanged lines hidden (view full) --- 1006 savech = *cp; 1007 *cp = '\0'; 1008 switch (specType) { 1009 case Suffixes: 1010 Suff_AddSuffix(line); 1011 break; 1012 case ExPath: 1013 LST_FOREACH(ln, &paths) | 945 break; 946 case Posix: 947 Var_Set("%POSIX", "1003.2", VAR_GLOBAL); 948 break; 949 default: 950 break; 951 } 952 } else if (specType == MFlags) { --- 53 unchanged lines hidden (view full) --- 1006 savech = *cp; 1007 *cp = '\0'; 1008 switch (specType) { 1009 case Suffixes: 1010 Suff_AddSuffix(line); 1011 break; 1012 case ExPath: 1013 LST_FOREACH(ln, &paths) |
1014 Dir_AddDir(Lst_Datum(ln), line); | 1014 Path_AddDir(Lst_Datum(ln), line); |
1015 break; 1016 case Includes: 1017 Suff_AddInclude(line); 1018 break; 1019 case Libs: 1020 Suff_AddLib(line); 1021 break; 1022 case Null: --- 397 unchanged lines hidden (view full) --- 1420 * The directory is appended to the list. 1421 * 1422 *----------------------------------------------------------------------- 1423 */ 1424void 1425Parse_AddIncludeDir(char *dir) 1426{ 1427 | 1015 break; 1016 case Includes: 1017 Suff_AddInclude(line); 1018 break; 1019 case Libs: 1020 Suff_AddLib(line); 1021 break; 1022 case Null: --- 397 unchanged lines hidden (view full) --- 1420 * The directory is appended to the list. 1421 * 1422 *----------------------------------------------------------------------- 1423 */ 1424void 1425Parse_AddIncludeDir(char *dir) 1426{ 1427 |
1428 Dir_AddDir(&parseIncPath, dir); | 1428 Path_AddDir(&parseIncPath, dir); |
1429} 1430 1431/*--------------------------------------------------------------------- 1432 * ParseDoError -- 1433 * Handle error directive 1434 * 1435 * The input is the line minus the ".error". We substitute variables, 1436 * print the message and exit(1) or just print a warning if the ".error" --- 149 unchanged lines hidden (view full) --- 1586 if (prefEnd != (char *)NULL) { 1587 char *newName; 1588 1589 *prefEnd = '\0'; 1590 if (file[0] == '/') 1591 newName = estrdup(file); 1592 else 1593 newName = str_concat(Fname, file, STR_ADDSLASH); | 1429} 1430 1431/*--------------------------------------------------------------------- 1432 * ParseDoError -- 1433 * Handle error directive 1434 * 1435 * The input is the line minus the ".error". We substitute variables, 1436 * print the message and exit(1) or just print a warning if the ".error" --- 149 unchanged lines hidden (view full) --- 1586 if (prefEnd != (char *)NULL) { 1587 char *newName; 1588 1589 *prefEnd = '\0'; 1590 if (file[0] == '/') 1591 newName = estrdup(file); 1592 else 1593 newName = str_concat(Fname, file, STR_ADDSLASH); |
1594 fullname = Dir_FindFile(newName, &parseIncPath); | 1594 fullname = Path_FindFile(newName, &parseIncPath); |
1595 if (fullname == NULL) { | 1595 if (fullname == NULL) { |
1596 fullname = Dir_FindFile(newName, &dirSearchPath); | 1596 fullname = Path_FindFile(newName, &dirSearchPath); |
1597 } 1598 free(newName); 1599 *prefEnd = '/'; 1600 } else { 1601 fullname = NULL; 1602 } 1603 free(Fname); 1604 } else { 1605 fullname = NULL; 1606 } 1607 1608 if (fullname == NULL) { 1609 /* 1610 * System makefile or makefile wasn't found in same directory as 1611 * included makefile. Search for it first on the -I search path, 1612 * then on the .PATH search path, if not found in a -I directory. 1613 * XXX: Suffix specific? 1614 */ | 1597 } 1598 free(newName); 1599 *prefEnd = '/'; 1600 } else { 1601 fullname = NULL; 1602 } 1603 free(Fname); 1604 } else { 1605 fullname = NULL; 1606 } 1607 1608 if (fullname == NULL) { 1609 /* 1610 * System makefile or makefile wasn't found in same directory as 1611 * included makefile. Search for it first on the -I search path, 1612 * then on the .PATH search path, if not found in a -I directory. 1613 * XXX: Suffix specific? 1614 */ |
1615 fullname = Dir_FindFile(file, &parseIncPath); | 1615 fullname = Path_FindFile(file, &parseIncPath); |
1616 if (fullname == NULL) { | 1616 if (fullname == NULL) { |
1617 fullname = Dir_FindFile(file, &dirSearchPath); | 1617 fullname = Path_FindFile(file, &dirSearchPath); |
1618 } 1619 } 1620 1621 if (fullname == NULL) { 1622 /* 1623 * Still haven't found the makefile. Look for it on the system 1624 * path as a last resort. 1625 */ | 1618 } 1619 } 1620 1621 if (fullname == NULL) { 1622 /* 1623 * Still haven't found the makefile. Look for it on the system 1624 * path as a last resort. 1625 */ |
1626 fullname = Dir_FindFile(file, &sysIncPath); | 1626 fullname = Path_FindFile(file, &sysIncPath); |
1627 } 1628 1629 if (fullname == NULL) { 1630 *cp = endc; 1631 Parse_Error(PARSE_FATAL, "Could not find %s", file); 1632 /* XXXHB free(file) */ 1633 return; 1634 } --- 120 unchanged lines hidden (view full) --- 1755 buf = Var_Subst(NULL, file, VAR_CMD, FALSE); 1756 file = Buf_Peel(buf); 1757 1758 /* 1759 * Now we know the file's name, we attempt to find the durn thing. 1760 * Search for it first on the -I search path, then on the .PATH 1761 * search path, if not found in a -I directory. 1762 */ | 1627 } 1628 1629 if (fullname == NULL) { 1630 *cp = endc; 1631 Parse_Error(PARSE_FATAL, "Could not find %s", file); 1632 /* XXXHB free(file) */ 1633 return; 1634 } --- 120 unchanged lines hidden (view full) --- 1755 buf = Var_Subst(NULL, file, VAR_CMD, FALSE); 1756 file = Buf_Peel(buf); 1757 1758 /* 1759 * Now we know the file's name, we attempt to find the durn thing. 1760 * Search for it first on the -I search path, then on the .PATH 1761 * search path, if not found in a -I directory. 1762 */ |
1763 fullname = Dir_FindFile(file, &parseIncPath); | 1763 fullname = Path_FindFile(file, &parseIncPath); |
1764 if (fullname == NULL) { | 1764 if (fullname == NULL) { |
1765 fullname = Dir_FindFile(file, &dirSearchPath); | 1765 fullname = Path_FindFile(file, &dirSearchPath); |
1766 } 1767 1768 if (fullname == NULL) { 1769 /* 1770 * Still haven't found the makefile. Look for it on the system 1771 * path as a last resort. 1772 */ | 1766 } 1767 1768 if (fullname == NULL) { 1769 /* 1770 * Still haven't found the makefile. Look for it on the system 1771 * path as a last resort. 1772 */ |
1773 fullname = Dir_FindFile(file, &sysIncPath); | 1773 fullname = Path_FindFile(file, &sysIncPath); |
1774 } 1775 1776 if (fullname == NULL) { 1777 Parse_Error(PARSE_FATAL, "Could not find %s", file); 1778 /* XXXHB free(file) */ 1779 return; 1780 } 1781 --- 709 unchanged lines hidden --- | 1774 } 1775 1776 if (fullname == NULL) { 1777 Parse_Error(PARSE_FATAL, "Could not find %s", file); 1778 /* XXXHB free(file) */ 1779 return; 1780 } 1781 --- 709 unchanged lines hidden --- |