Ticket #148: makedepend.patch
File makedepend.patch, 130.8 KB (added by , 17 years ago) |
---|
-
ifparser.h
78 78 const char *, 79 79 long * 80 80 ); 81 82 /*83 * Copyright 1992 Network Computing Devices, Inc.84 *85 * Permission to use, copy, modify, and distribute this software and its86 * documentation for any purpose and without fee is hereby granted, provided87 * that the above copyright notice appear in all copies and that both that88 * copyright notice and this permission notice appear in supporting89 * documentation, and that the name of Network Computing Devices may not be90 * used in advertising or publicity pertaining to distribution of the software91 * without specific, written prior permission. Network Computing Devices makes92 * no representations about the suitability of this software for any purpose.93 * It is provided ``as is'' without express or implied warranty.94 *95 * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS96 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,97 * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,98 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM99 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE100 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR101 * PERFORMANCE OF THIS SOFTWARE.102 *103 * Author: Jim Fulton104 * Network Computing Devices, Inc.105 *106 * Simple if statement processor107 *108 * This module can be used to evaluate string representations of C language109 * if constructs. It accepts the following grammar:110 *111 * EXPRESSION := VALUE112 * | VALUE BINOP EXPRESSION113 * | VALUE '?' EXPRESSION ':' EXPRESSION114 *115 * VALUE := '(' EXPRESSION ')'116 * | '!' VALUE117 * | '-' VALUE118 * | '~' VALUE119 * | 'defined' '(' variable ')'120 * | variable121 * | number122 *123 * BINOP := '*' | '/' | '%'124 * | '+' | '-'125 * | '<<' | '>>'126 * | '<' | '>' | '<=' | '>='127 * | '==' | '!='128 * | '&' | '^' | '|'129 * | '&&' | '||'130 *131 * The normal C order of precedence is supported.132 *133 *134 * External Entry Points:135 *136 * ParseIfExpression parse a string for #if137 */138 139 /* $Header: /code/makedepend/ifparser.h,v 1.2 2004/04/20 19:50:26 doj Exp $ */140 141 #include <stdio.h>142 143 typedef int Bool;144 #define False 0145 #define True 1146 147 typedef struct _if_parser {148 struct { /* functions */149 const char *(*handle_error) (struct _if_parser *, const char *,150 const char *);151 long (*eval_variable) (struct _if_parser *, const char *, int);152 int (*eval_defined) (struct _if_parser *, const char *, int);153 } funcs;154 char *data;155 } IfParser;156 157 const char *ParseIfExpression (158 IfParser *,159 const char *,160 long *161 );162 -
imakemdep.h
1426 1426 # endif /* MAKEDEPEND */ 1427 1427 1428 1428 #endif /* CCIMAKE */ 1429 /*1430 1431 Copyright (c) 1993, 1994, 1998 The Open Group1432 1433 Permission to use, copy, modify, distribute, and sell this software and its1434 documentation for any purpose is hereby granted without fee, provided that1435 the above copyright notice appear in all copies and that both that1436 copyright notice and this permission notice appear in supporting1437 documentation.1438 1439 The above copyright notice and this permission notice shall be included in1440 all copies or substantial portions of the Software.1441 1442 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR1443 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,1444 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE1445 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN1446 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN1447 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.1448 1449 Except as contained in this notice, the name of The Open Group shall not be1450 used in advertising or otherwise to promote the sale, use or other dealings1451 in this Software without prior written authorization from The Open Group.1452 1453 */1454 /* $Header: /code/makedepend/imakemdep.h,v 1.2 2004/04/20 19:50:26 doj Exp $ */1455 1456 1457 /*1458 * This file contains machine-dependent constants for the imake utility.1459 * When porting imake, read each of the steps below and add in any necessary1460 * definitions. In general you should *not* edit ccimake.c or imake.c!1461 */1462 1463 #ifdef __UNIXOS2__1464 #define lstat stat1465 #endif1466 1467 #ifdef CCIMAKE1468 /*1469 * Step 1: imake_ccflags1470 * Define any special flags that will be needed to get imake.c to compile.1471 * These will be passed to the compile along with the contents of the1472 * make variable BOOTSTRAPCFLAGS.1473 */1474 #if defined(clipper) || defined(__clipper__)1475 #define imake_ccflags "-O -DSYSV -DBOOTSTRAPCFLAGS=-DSYSV"1476 #endif1477 1478 #ifdef hpux1479 #ifdef hp9000s8001480 #define imake_ccflags "-DSYSV"1481 #else1482 #define imake_ccflags "-Wc,-Nd4000,-Ns3000 -DSYSV"1483 #endif1484 #endif1485 1486 #if defined(macII) || defined(_AUX_SOURCE)1487 #define imake_ccflags "-DmacII -DSYSV"1488 #endif1489 1490 #ifdef stellar1491 #define imake_ccflags "-DSYSV"1492 #endif1493 1494 #if defined(USL) || defined(__USLC__) || defined(Oki) || defined(NCR)1495 #define imake_ccflags "-Xa -DSVR4"1496 #endif1497 1498 /* SCO may define __USLC__ so put this after the USL check */1499 #if defined(M_UNIX) || defined(_SCO_DS)1500 #ifdef imake_ccflags1501 #undef imake_ccflags1502 #endif1503 #define imake_ccflags "-Dsco -DSYSV -DSCO -DSCO325"1504 #endif1505 1506 #ifdef sony1507 #if defined(SYSTYPE_SYSV) || defined(_SYSTYPE_SYSV)1508 #define imake_ccflags "-DSVR4"1509 #else1510 #include <sys/param.h>1511 #if NEWSOS < 411512 #define imake_ccflags "-Dbsd43 -DNOSTDHDRS"1513 #else1514 #if NEWSOS < 421515 #define imake_ccflags "-Dbsd43"1516 #endif1517 #endif1518 #endif1519 #endif1520 #ifdef _CRAY1521 #define imake_ccflags "-DSYSV -DUSG"1522 #endif1523 1524 #if defined(_IBMR2) || defined(aix)1525 #define imake_ccflags "-Daix -DSYSV"1526 #endif1527 1528 #ifdef Mips1529 # if defined(SYSTYPE_BSD) || defined(BSD) || defined(BSD43)1530 # define imake_ccflags "-DBSD43"1531 # else1532 # define imake_ccflags "-DSYSV"1533 # endif1534 #endif1535 1536 #ifdef is68k1537 #define imake_ccflags "-Dluna -Duniosb"1538 #endif1539 1540 #ifdef SYSV3861541 # ifdef SVR41542 # define imake_ccflags "-Xa -DSVR4"1543 # else1544 # define imake_ccflags "-DSYSV"1545 # endif1546 #endif1547 1548 #ifdef SVR41549 # ifdef i3861550 # define imake_ccflags "-Xa -DSVR4"1551 # endif1552 #endif1553 1554 #ifdef SYSV1555 # ifdef i3861556 # define imake_ccflags "-DSYSV"1557 # endif1558 #endif1559 1560 #if defined(Lynx) || defined(__Lynx__)1561 #define imake_ccflags "-DLynx"1562 #endif /* Lynx */1563 1564 #ifdef __convex__1565 #define imake_ccflags "-fn -tm c1"1566 #endif1567 1568 #ifdef apollo1569 #define imake_ccflags "-DX_NOT_POSIX"1570 #endif1571 1572 #ifdef WIN321573 #if _MSC_VER < 10001574 #define imake_ccflags "-nologo -batch -D__STDC__"1575 #else1576 #define imake_ccflags "-nologo -D__STDC__"1577 #endif1578 #endif1579 1580 #ifdef __uxp__1581 #define imake_ccflags "-DSVR4 -DANSICPP"1582 #endif1583 1584 #ifdef __sxg__1585 #define imake_ccflags "-DSYSV -DUSG -DNOSTDHDRS"1586 #endif1587 1588 #ifdef _SEQUENT_1589 #define imake_ccflags "-Xa -DSVR4"1590 #endif1591 1592 #if defined(SX) || defined(PC_UX)1593 #define imake_ccflags "-DSYSV"1594 #endif1595 1596 #ifdef nec_ews_svr21597 #define imake_ccflags "-DUSG"1598 #endif1599 1600 #if defined(nec_ews_svr4) || defined(_nec_ews_svr4) || defined(_nec_up) || defined(_nec_ft)1601 #define imake_ccflags "-DSVR4"1602 #endif1603 1604 #if defined(MACH) && !defined(__GNU__)1605 #define imake_ccflags "-DNOSTDHDRS"1606 #endif1607 1608 /* this is for OS/2 under UNIXOS2. This won't work with DOS */1609 #if defined(__UNIXOS2__)1610 #define imake_ccflags "-DBSD43"1611 #endif1612 1613 #if defined(__QNX__) && !defined(__QNXNTO__)1614 #define imake_ccflags "-D__QNX__ -D_i386"1615 #endif1616 1617 #if defined(__QNXNTO__)1618 #define imake_ccflags "-D__QNXNTO__"1619 #endif1620 1621 #else /* not CCIMAKE */1622 #ifndef MAKEDEPEND1623 /*1624 * Step 2: dup21625 * If your OS doesn't have a dup2() system call to duplicate one file1626 * descriptor onto another, define such a mechanism here (if you don't1627 * already fall under the existing category(ies).1628 */1629 #if defined(SYSV) && !defined(_CRAY) && !defined(Mips) && !defined(_SEQUENT_) && !defined(sco)1630 #define dup2(fd1,fd2) ((fd1 == fd2) ? fd1 : (close(fd2), \1631 fcntl(fd1, F_DUPFD, fd2)))1632 #endif1633 1634 1635 /*1636 * Step 3: FIXUP_CPP_WHITESPACE1637 * If your cpp collapses tabs in macro expansions into a single space and1638 * replaces escaped newlines with a space, define this symbol. This will1639 * cause imake to attempt to patch up the generated Makefile by looking1640 * for lines that have colons in them (this is why the rules file escapes1641 * all colons). One way to tell if you need this is to see whether or not1642 * your Makefiles have no tabs in them and lots of @@ strings.1643 */1644 #if defined(sun) || defined(SYSV) || defined(SVR4) || defined(hcx) || defined(WIN32) || defined(sco) || (defined(AMOEBA) && defined(CROSS_COMPILE)) || defined(__QNX__) || defined(__sgi) || defined(__UNIXOS2__)1645 #define FIXUP_CPP_WHITESPACE1646 #endif1647 #ifdef WIN321648 #define REMOVE_CPP_LEADSPACE1649 #define INLINE_SYNTAX1650 #define MAGIC_MAKE_VARS1651 #endif1652 #ifdef __minix_vmd1653 #define FIXUP_CPP_WHITESPACE1654 #endif1655 1656 #if defined(Lynx)1657 /* On LynxOS 2.4.0 imake gets built with the old "legacy"1658 * /bin/cc which has a rather pedantic builtin preprocessor.1659 * Using a macro which is not #defined (as in Step 51660 * below) flags an *error*1661 */1662 #define __NetBSD_Version__ 01663 #endif1664 1665 /*1666 * Step 4: USE_CC_E, DEFAULT_CC, DEFAULT_CPP1667 * If you want to use cc -E instead of cpp, define USE_CC_E.1668 * If use cc -E but want a different compiler, define DEFAULT_CC.1669 * If the cpp you need is not in /lib/cpp, define DEFAULT_CPP.1670 */1671 #if !defined (CROSSCOMPILE) || defined (CROSSCOMPILE_CPP)1672 1673 #if defined(__APPLE__)1674 #define DEFAULT_CPP "/usr/bin/cpp"1675 #define DEFAULT_CC "cc"1676 #endif1677 #if defined(Lynx) || defined(__Lynx__)1678 #define DEFAULT_CC "gcc"1679 #define USE_CC_E1680 #endif1681 #ifdef hpux1682 #define USE_CC_E1683 #endif1684 #ifdef WIN321685 #define USE_CC_E1686 #define DEFAULT_CC "cl"1687 #endif1688 #ifdef apollo1689 #define DEFAULT_CPP "/usr/lib/cpp"1690 #endif1691 #if defined(clipper) || defined(__clipper__)1692 #define DEFAULT_CPP "/usr/lib/cpp"1693 #endif1694 #if defined(_IBMR2) && !defined(DEFAULT_CPP)1695 #define DEFAULT_CPP "/usr/ccs/lib/cpp"1696 #endif1697 #if defined(sun) && (defined(SVR4) || defined(__svr4__) || defined(__SVR4) || defined(__sol__))1698 #define DEFAULT_CPP "/usr/ccs/lib/cpp"1699 #endif1700 #ifdef __bsdi__1701 #define DEFAULT_CPP "/usr/bin/cpp"1702 #endif1703 #ifdef __uxp__1704 #define DEFAULT_CPP "/usr/ccs/lib/cpp"1705 #endif1706 #ifdef __sxg__1707 #define DEFAULT_CPP "/usr/lib/cpp"1708 #endif1709 #ifdef _CRAY1710 #define DEFAULT_CPP "/lib/pcpp"1711 #endif1712 #if defined(__386BSD__)1713 #define DEFAULT_CPP "/usr/libexec/cpp"1714 #endif1715 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)1716 #define USE_CC_E1717 #endif1718 #if defined(__sgi) && defined(__ANSI_CPP__)1719 #define USE_CC_E1720 #endif1721 #if defined(MACH) && !defined(__GNU__)1722 #define USE_CC_E1723 #endif1724 #ifdef __minix_vmd1725 #define DEFAULT_CPP "/usr/lib/cpp"1726 #endif1727 #if defined(__UNIXOS2__)1728 /* expects cpp in PATH */1729 #define DEFAULT_CPP "cpp"1730 #endif1731 #ifdef __CYGWIN__1732 #define DEFAULT_CC "gcc"1733 #define DEFAULT_CPP "/usr/bin/cpp"1734 #endif1735 #if defined (__QNX__)1736 #ifdef __QNXNTO__1737 #define DEFAULT_CPP "/usr/bin/cpp"1738 #else1739 #define DEFAULT_CPP "/usr/X11R6/bin/cpp"1740 #endif1741 #endif1742 #if defined(__GNUC__) && !defined(USE_CC_E)1743 #define USE_CC_E1744 #ifndef DEFAULT_CC1745 #define DEFAULT_CC "gcc"1746 #endif1747 #endif1748 1749 #endif /* !defined (CROSSCOMPILE) || defined (CROSSCOMPILE_CPP) */1750 /*1751 * Step 5: cpp_argv1752 * The following table contains the flags that should be passed1753 * whenever a Makefile is being generated. If your preprocessor1754 * doesn't predefine any unique symbols, choose one and add it to the1755 * end of this table. Then, do the following:1756 *1757 * a. Use this symbol in Imake.cf when setting MacroFile.1758 * b. Put this symbol in the definition of BootstrapCFlags in your1759 * <platform>.cf file.1760 * c. When doing a make World, always add "BOOTSTRAPCFLAGS=-Dsymbol"1761 * to the end of the command line.1762 *1763 * Note that you may define more than one symbol (useful for platforms1764 * that support multiple operating systems).1765 */1766 1767 #define ARGUMENTS 50 /* number of arguments in various arrays */1768 #if !defined (CROSSCOMPILE) || defined (CROSSCOMPILE_CPP)1769 char *cpp_argv[ARGUMENTS] = {1770 "cc", /* replaced by the actual program to exec */1771 "-I.", /* add current directory to include path */1772 #if !defined(__NetBSD_Version__) || __NetBSD_Version__ < 1030800001773 #ifdef unix1774 "-Uunix", /* remove unix symbol so that filename unix.c okay */1775 #endif1776 #endif1777 #if defined(__386BSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \1778 defined(__FreeBSD__) || defined(MACH) || defined(linux) || \1779 defined(__GNU__) || defined(__bsdi__) || defined(__GNUC__)1780 # ifdef __i386__1781 "-D__i386__",1782 # if defined(__GNUC__) && (__GNUC__ >= 3)1783 "-m32",1784 # endif1785 # endif1786 # ifdef __i486__1787 "-D__i486__",1788 # endif1789 # ifdef __i586__1790 "-D__i586__",1791 # endif1792 # ifdef __i686__1793 "-D__i686__",1794 # endif1795 # ifdef __k6__1796 "-D__k6__",1797 # endif1798 # ifdef __ia64__1799 "-D__ia64__",1800 # endif1801 # ifdef __AMD64__1802 "-D__AMD64__",1803 # endif1804 # ifdef __x86_64__1805 "-D__AMD64__",1806 # endif1807 # ifdef __s390__1808 "-D__s390__",1809 # endif1810 # ifdef __alpha__1811 "-D__alpha__",1812 # endif1813 # ifdef __arm__1814 "-D__arm__",1815 # endif1816 # ifdef __s390x__1817 "-D__s390x__",1818 # endif1819 # ifdef __sparc__1820 "-D__sparc__",1821 # endif1822 # ifdef __m68k__1823 "-D__m68k__",1824 # endif1825 # ifdef __sh__1826 "-D__sh__",1827 # endif1828 # ifdef __sh3__1829 "-D__sh3__",1830 # endif1831 # ifdef __SH3__1832 "-D__SH3__",1833 # endif1834 # ifdef __SH4__1835 "-D__SH4__",1836 # endif1837 # ifdef __SH4NOFPU__1838 "-D__SH4_NOFPU__",1839 # endif1840 # ifdef __GNUC__1841 "-traditional",1842 # endif1843 #endif1844 #ifdef M43301845 "-DM4330", /* Tektronix */1846 #endif1847 #ifdef M43101848 "-DM4310", /* Tektronix */1849 #endif1850 #if defined(macII) || defined(_AUX_SOURCE)1851 "-DmacII", /* Apple A/UX */1852 #endif1853 #if defined(USL) || defined(__USLC__)1854 "-DUSL", /* USL */1855 #endif1856 #ifdef sony1857 "-Dsony", /* Sony */1858 #if !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV) && NEWSOS < 421859 "-Dbsd43",1860 #endif1861 #endif1862 #ifdef _IBMR21863 "-D_IBMR2", /* IBM RS-6000 (we ensured that aix is defined above */1864 #ifndef aix1865 #define aix /* allow BOOTSTRAPCFLAGS="-D_IBMR2" */1866 #endif1867 #endif /* _IBMR2 */1868 #ifdef aix1869 "-Daix", /* AIX instead of AOS */1870 #ifndef ibm1871 #define ibm /* allow BOOTSTRAPCFLAGS="-Daix" */1872 #endif1873 #endif /* aix */1874 #ifdef ibm1875 "-Dibm", /* IBM PS/2 and RT under both AOS and AIX */1876 #endif1877 #ifdef luna1878 "-Dluna", /* OMRON luna 68K and 88K */1879 #ifdef luna11880 "-Dluna1",1881 #endif1882 #ifdef luna88k /* need not on UniOS-Mach Vers. 1.13 */1883 "-traditional", /* for some older version */1884 #endif /* instead of "-DXCOMM=\\#" */1885 #ifdef uniosb1886 "-Duniosb",1887 #endif1888 #ifdef uniosu1889 "-Duniosu",1890 #endif1891 #endif /* luna */1892 #ifdef _CRAY /* Cray */1893 "-Ucray",1894 #endif1895 #ifdef Mips1896 "-DMips", /* Define and use Mips for Mips Co. OS/mach. */1897 # if defined(SYSTYPE_BSD) || defined(BSD) || defined(BSD43)1898 "-DBSD43", /* Mips RISCOS supports two environments */1899 # else1900 "-DSYSV", /* System V environment is the default */1901 # endif1902 #endif /* Mips */1903 #ifdef MOTOROLA1904 "-DMOTOROLA", /* Motorola Delta Systems */1905 # ifdef SYSV1906 "-DSYSV",1907 # endif1908 # ifdef SVR41909 "-DSVR4",1910 # endif1911 #endif /* MOTOROLA */1912 #if defined(M_UNIX) || defined(sco)1913 "-Dsco",1914 "-DSYSV",1915 #endif1916 #ifdef i3861917 "-Di386",1918 # ifdef SVR41919 "-DSVR4",1920 # endif1921 # ifdef SYSV1922 "-DSYSV",1923 # ifdef ISC1924 "-DISC",1925 # ifdef ISC401926 "-DISC40", /* ISC 4.0 */1927 # else1928 # ifdef ISC2021929 "-DISC202", /* ISC 2.0.2 */1930 # else1931 # ifdef ISC301932 "-DISC30", /* ISC 3.0 */1933 # else1934 "-DISC22", /* ISC 2.2.1 */1935 # endif1936 # endif1937 # endif1938 # endif1939 # ifdef SCO1940 "-DSCO",1941 # ifdef _SCO_DS1942 "-DSCO325",1943 # endif1944 # endif1945 # endif1946 # ifdef ESIX1947 "-DESIX",1948 # endif1949 # ifdef ATT1950 "-DATT",1951 # endif1952 # ifdef DELL1953 "-DDELL",1954 # endif1955 #endif1956 #ifdef SYSV386 /* System V/386 folks, obsolete */1957 "-Di386",1958 # ifdef SVR41959 "-DSVR4",1960 # endif1961 # ifdef ISC1962 "-DISC",1963 # ifdef ISC401964 "-DISC40", /* ISC 4.0 */1965 # else1966 # ifdef ISC2021967 "-DISC202", /* ISC 2.0.2 */1968 # else1969 # ifdef ISC301970 "-DISC30", /* ISC 3.0 */1971 # else1972 "-DISC22", /* ISC 2.2.1 */1973 # endif1974 # endif1975 # endif1976 # endif1977 # ifdef SCO1978 "-DSCO",1979 # ifdef _SCO_DS1980 "-DSCO325",1981 # endif1982 # endif1983 # ifdef ESIX1984 "-DESIX",1985 # endif1986 # ifdef ATT1987 "-DATT",1988 # endif1989 # ifdef DELL1990 "-DDELL",1991 # endif1992 #endif1993 #ifdef __osf__1994 "-D__osf__",1995 # ifdef __mips__1996 "-D__mips__",1997 # endif1998 # ifdef __alpha1999 "-D__alpha",2000 # endif2001 # ifdef __amiga__2002 "-D__amiga__",2003 # endif2004 # ifdef __alpha__2005 "-D__alpha__",2006 # endif2007 # ifdef __i386__2008 "-D__i386__",2009 # endif2010 # ifdef __GNUC__2011 "-traditional",2012 # endif2013 #endif2014 #ifdef Oki2015 "-DOki",2016 #endif2017 #ifdef sun2018 #if defined(SVR4) || defined(__svr4__) || defined(__SVR4) || defined(__sol__)2019 "-DSVR4",2020 #endif2021 #endif2022 #ifdef WIN322023 "-DWIN32",2024 "-nologo",2025 #if _MSC_VER < 10002026 "-batch",2027 #endif2028 "-D__STDC__",2029 #endif2030 #ifdef NCR2031 "-DNCR", /* NCR */2032 #endif2033 #ifdef linux2034 "-Dlinux",2035 #endif2036 #if defined(__CYGWIN__)2037 "-traditional",2038 #endif2039 #if defined(Lynx) || defined(__Lynx__)2040 "-traditional",2041 #if 02042 "-DLYNX", /* do we really need this?? */2043 #endif2044 "-DLynx",2045 # ifdef ppc2046 "-Dppc",2047 # endif2048 # if defined(m68k) || defined(M68k) || defined(m68040)2049 "-Dm68k",2050 "-DM68k",2051 # endif2052 # ifdef uSPARC12053 "-Dsparc",2054 # endif2055 #endif2056 #ifdef __uxp__2057 "-D__uxp__",2058 #endif2059 #ifdef __sxg__2060 "-D__sxg__",2061 #endif2062 #ifdef nec_ews_svr22063 "-Dnec_ews_svr2",2064 #endif2065 #ifdef AMOEBA2066 "-DAMOEBA",2067 # ifdef CROSS_COMPILE2068 "-DCROSS_COMPILE",2069 # ifdef CROSS_i803862070 "-Di80386",2071 # endif2072 # ifdef CROSS_sparc2073 "-Dsparc",2074 # endif2075 # ifdef CROSS_mc680002076 "-Dmc68000",2077 # endif2078 # else2079 # ifdef i803862080 "-Di80386",2081 # endif2082 # ifdef sparc2083 "-Dsparc",2084 # endif2085 # ifdef mc680002086 "-Dmc68000",2087 # endif2088 # endif2089 #endif2090 #if defined(__sgi) && defined(__ANSI_CPP__)2091 "-cckr",2092 #endif2093 #ifdef __minix_vmd2094 "-Dminix",2095 #endif2096 2097 #if defined(__UNIXOS2__)2098 "-traditional",2099 "-Demxos2",2100 #endif2101 #ifdef MetroLink2102 "-DMetroLink",2103 # ifdef SVR42104 "-DSVR4",2105 # endif2106 # ifdef __powerpc__2107 "-D__powerpc__",2108 # endif2109 # ifdef PowerMAX_OS2110 "-DPowerMAX_OS",2111 # endif2112 #endif2113 #if defined (__QNX__) && !defined(__QNXNTO__)2114 "-traditional",2115 "-D__QNX__",2116 #endif2117 2118 #if defined(__QNXNTO__)2119 "-traditional",2120 "-D__QNXNTO__",2121 #if defined(i386)2122 "-Di386",2123 #endif2124 #if defined(__i386__)2125 "-D__i386__",2126 #endif2127 #if defined(PPC)2128 "-DPPC",2129 #endif2130 #if defined(MIPS)2131 "-DMIPS",2132 #endif2133 #endif2134 2135 #if defined(__APPLE__)2136 "-D__APPLE__",2137 "-D__DARWIN__",2138 # ifdef __ppc__2139 "-D__ppc__",2140 # endif2141 # ifdef __i386__2142 "-D__i386__",2143 # endif2144 #endif2145 };2146 #endif /* CROSSCOMPILE */2147 2148 2149 /*2150 * Step 6: DEFAULT_OS_MAJOR_REV, DEFAULT_OS_MINOR_REV, DEFAULT_OS_TEENY_REV,2151 * and DEFAULT_OS_NAME.2152 * If your system provides a way to generate the default major,2153 * minor, teeny, or system names at runtime add commands below.2154 * The syntax of the _REV strings is 'f fmt' where 'f' is an argument2155 * you would give to uname, and "fmt" is a scanf() format string.2156 * Supported uname arguments are "snrvm", and if you specify multiple2157 * arguments they will be separated by spaces. No more than 5 arguments2158 * may be given. Unlike uname() order of arguments matters.2159 *2160 * DEFAULT_OS_MAJOR_REV_FROB, DEFAULT_OS_MINOR_REV_FROB,2161 * DEFAULT_OS_TEENY_REV_FROB, and DEFAULT_OS_NAME_FROB can be used to2162 * modify the results of the use of the various strings.2163 */2164 #if !defined CROSSCOMPILE || defined CROSSCOMPILE_CPP2165 # if defined(aix)2166 /* uname -v returns "x" (e.g. "4"), and uname -r returns "y" (e.g. "1") */2167 # define DEFAULT_OS_MAJOR_REV "v %[0-9]"2168 # define DEFAULT_OS_MINOR_REV "r %[0-9]"2169 /* No information available to generate default OSTeenyVersion value. */2170 # define DEFAULT_OS_NAME "srvm %[^\n]"2171 # elif defined(sun) || defined(sgi) || defined(ultrix) || defined(__uxp__) || defined(sony)2172 /* uname -r returns "x.y[.z]", e.g. "5.4" or "4.1.3" */2173 # define DEFAULT_OS_MAJOR_REV "r %[0-9]"2174 # define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"2175 # define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"2176 # define DEFAULT_OS_NAME "srvm %[^\n]"2177 # elif defined(hpux)2178 /* uname -r returns "W.x.yz", e.g. "B.10.01" */2179 # define DEFAULT_OS_MAJOR_REV "r %*[^.].%[0-9]"2180 # define DEFAULT_OS_MINOR_REV "r %*[^.].%*d.%1s"2181 # define DEFAULT_OS_TEENY_REV "r %*[^.].%*d.%*c%[0-9]"2182 # define DEFAULT_OS_NAME "srvm %[^\n]"2183 # elif defined(USL) || defined(__USLC__)2184 /* uname -v returns "x.yz" or "x.y.z", e.g. "2.02" or "2.1.2". */2185 # define DEFAULT_OS_MAJOR_REV "v %[0-9]"2186 # define DEFAULT_OS_MINOR_REV "v %*d.%1s"2187 # define DEFAULT_OS_TEENY_REV "v %*d.%*c%[.0-9]"2188 # define DEFAULT_OS_NAME "srvm %[^\n]"2189 # elif defined(__APPLE__)2190 /* uname -v returns "x.yz" or "x.y.z", e.g. "2.02" or "2.1.2". */2191 # define DEFAULT_OS_MAJOR_REV "r %[0-9]"2192 # define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"2193 # define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]" /* this will just get 0 */2194 # define DEFAULT_OS_NAME "s %[^\n]"2195 # elif defined(__osf__)2196 /* uname -r returns "Wx.y", e.g. "V3.2" or "T4.0" */2197 # define DEFAULT_OS_MAJOR_REV "r %*[^0-9]%[0-9]"2198 # define DEFAULT_OS_MINOR_REV "r %*[^.].%[0-9]"2199 # define DEFAULT_OS_NAME "srvm %[^\n]"2200 # elif defined(__uxp__)2201 /* NOTE: "x.y[.z]" above handles UXP/DF. This is a sample alternative. */2202 /* uname -v returns "VxLy Yzzzzz ....", e.g. "V20L10 Y95021 Increment 5 ..." */2203 # define DEFAULT_OS_MAJOR_REV "v V%[0-9]"2204 # define DEFAULT_OS_MINOR_REV "v V%*dL%[0-9]"2205 # define DEFAULT_OS_NAME "srvm %[^\n]"2206 # elif defined(linux) || defined(__bsdi__)2207 # define DEFAULT_OS_MAJOR_REV "r %[0-9]"2208 # define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"2209 # define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"2210 # define DEFAULT_OS_NAME "srm %[^\n]"2211 # if defined(linux) && defined (CROSSCOMPILE_CPP)2212 # define CROSS_UTS_SYSNAME "Linux"2213 # include <linux/version.h>2214 # define CROSS_UTS_RELEASE UTS_RELEASE2215 # endif2216 # elif defined(__CYGWIN__)2217 # define DEFAULT_OS_MAJOR_REV "r %[0-9]"2218 # define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"2219 # define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"2220 # define DEFAULT_OS_NAME "srm %[^\n]"2221 # if defined(__CYGWIN__) && defined (CROSSCOMPILE_CPP)2222 # define CROSS_UTS_SYSNAME "Cygwin"2223 # include <cygwin/version.h>2224 # define CROSS_UTS_RELEASE "1.3.12"2225 # endif2226 # elif defined(__GNU__)2227 # define DEFAULT_OS_MAJOR_REV "r %[0-9]"2228 # define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"2229 # define DEFAULT_OS_NAME "srm %[^\n]"2230 # elif defined(ISC)2231 /* ISC all Versions ? */2232 /* uname -r returns "x.y", e.g. "3.2" ,uname -v returns "x" e.g. "2" */2233 # define DEFAULT_OS_MAJOR_REV "r %[0-9]"2234 # define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"2235 # define DEFAULT_OS_TEENY_REV "v %[0-9]"2236 /* # define DEFAULT_OS_NAME "srm %[^\n]" */ /* Not useful on ISC */2237 # elif defined(__FreeBSD__) || defined(__OpenBSD__)2238 /* BSD/OS too? */2239 /* uname -r returns "x.y[.z]-mumble", e.g. "2.1.5-RELEASE" or "2.2-0801SNAP" */2240 # define DEFAULT_OS_MAJOR_REV "r %[0-9]"2241 # define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"2242 # define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"2243 # define DEFAULT_OS_NAME "srm %[^\n]"2244 # if defined(__FreeBSD__)2245 /* Use an alternate way to find the teeny version for -STABLE, -SNAP versions */2246 # ifndef CROSSCOMPILE_CPP2247 # define DEFAULT_OS_TEENY_REV_FROB(buf, size) \2248 do { \2249 if (*buf == 0) { \2250 int __mib[2]; \2251 size_t __len; \2252 int __osrel; \2253 \2254 __mib[0] = CTL_KERN; \2255 __mib[1] = KERN_OSRELDATE; \2256 __len = sizeof(__osrel); \2257 sysctl(__mib, 2, &__osrel, &__len, NULL, 0); \2258 if (__osrel < 210000) { \2259 if (__osrel < 199607) \2260 buf[0] = '0'; \2261 else if (__osrel < 199612) \2262 buf[0] = '5'; \2263 else if (__osrel == 199612) \2264 buf[0] = '6'; \2265 else \2266 buf[0] = '8'; /* guess */ \2267 } else { \2268 buf[0] = ((__osrel / 1000) % 10) + '0'; \2269 } \2270 buf[1] = 0; \2271 } \2272 } while (0)2273 # endif2274 # else2275 /* OpenBSD - Add DEFAULT_MACHINE_ARCHITECTURE */2276 # define DEFAULT_MACHINE_ARCHITECTURE "m %[^\n]"2277 # endif2278 # elif defined(__NetBSD__)2279 /*2280 * uname -r returns "x.y([ABCD...]|_mumble)", e.g.:2281 * 1.2 1.2_BETA 1.2A 1.2B2282 *2283 * That means that we have to do something special to turn the2284 * TEENY revision into a form that we can use (i.e., a string of2285 * decimal digits).2286 *2287 * We also frob the name DEFAULT_OS_NAME so that it looks like the2288 * 'standard' NetBSD name for the version, e.g. "NetBSD/i386 1.2B" for2289 * NetBSD 1.2B on an i386.2290 */2291 # define DEFAULT_OS_MAJOR_REV "r %[0-9]"2292 # define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"2293 # define DEFAULT_OS_TEENY_REV "r %*d.%*d%[A-Z]"2294 # define DEFAULT_OS_TEENY_REV_FROB(buf, size) \2295 do { \2296 int teeny = 0; \2297 char *ptr = (buf); \2298 \2299 while (*ptr >= 'A' && *ptr <= 'Z') /* sanity check */ \2300 teeny = teeny * 26 + (int)(*ptr++ - 'A'); \2301 \2302 snprintf((buf), (size), "%d", teeny + 1); \2303 } while (0)2304 # define DEFAULT_OS_NAME "smr %[^\n]"2305 # define DEFAULT_OS_NAME_FROB(buf, size) \2306 do { \2307 char *__sp; \2308 if ((__sp = strchr((buf), ' ')) != NULL) \2309 *__sp = '/'; \2310 } while (0)2311 # elif defined(__Lynx__) || defined(Lynx)2312 /* Lynx 2.4.0 /bin/cc doesn't like #elif */2313 # define DEFAULT_OS_MAJOR_REV "r %[0-9]"2314 # define DEFAULT_OS_MINOR_REV "r %*d.%[0-9]"2315 # define DEFAULT_OS_TEENY_REV "r %*d.%*d.%[0-9]"2316 # define DEFAULT_OS_NAME "srm %[^\n]"2317 # elif defined(_SEQUENT_)2318 /* uname -v returns 'Vx.y.z', e.g. 'V4.4.2' */2319 # define DEFAULT_OS_MAJOR_REV "v V%[0-9]"2320 # define DEFAULT_OS_MINOR_REV "v V%*d.%[0-9]"2321 # define DEFAULT_OS_TEENY_REV "v V%*d.%*d.%[0-9]"2322 # define DEFAULT_OS_NAME "s %[^\n]"2323 # endif2324 #endif /* !defined CROSSCOMPILE || defined CROSSCOMPILE_CPP */2325 2326 # if defined (CROSSCOMPILE_CPP)2327 # ifndef CROSS_UTS_SYSNAME2328 char *cross_uts_sysname = "";2329 # else2330 char *cross_uts_sysname = CROSS_UTS_SYSNAME;2331 # endif2332 # ifndef CROSS_UTS_RELEASE2333 char* cross_uts_release = "";2334 # else2335 char* cross_uts_release = CROSS_UTS_RELEASE;2336 # endif2337 # ifndef CROSS_UTS_MACHINE2338 char *cross_uts_machine = "";2339 # else2340 char *cross_uts_machine = CROSS_UTS_MACHINE;2341 # endif2342 # ifndef CROSS_UTS_VERSION2343 char * cross_uts_version = "";2344 # else2345 char * cross_uts_version = CROSS_UTS_VERSION;2346 # endif2347 # ifdef DEFAULT_OS_NAME2348 char *defaultOsName = DEFAULT_OS_NAME;2349 # else2350 char *defaultOsName = NULL;2351 # endif2352 # ifdef DEFAULT_OS_MAJOR_REV2353 char *defaultOsMajorRev = DEFAULT_OS_MAJOR_REV;2354 # else2355 char *defaultOsMajorRev = NULL;2356 # endif2357 # ifdef DEFAULT_OS_MINOR_REV2358 char *defaultOsMinorRev = DEFAULT_OS_MINOR_REV;2359 # else2360 char *defaultOsMinorRev = NULL;2361 # endif2362 # ifdef DEFAULT_OS_TEENY_REV2363 char *defaultOsTeenyRev = DEFAULT_OS_TEENY_REV;2364 # else2365 char *defaultOsTeenyRev = NULL;2366 # endif2367 # ifdef DEFAULT_MACHINE_ARCHITECTURE2368 char *defaultMachineArchitecture = DEFAULT_MACHINE_ARCHITECTURE;2369 # else2370 char *defaultMachineArchitecture = NULL;2371 # endif2372 # ifdef DEFAULT_OS_NAME_FROB2373 void defaultOsNameFrob(char *buf, int size)2374 {DEFAULT_OS_NAME_FROB(buf,size)}2375 # else2376 void (*defaultOsNameFrob)(char *buf, int size) = NULL;2377 # endif2378 # ifdef DEFAULT_OS_MAJOR_REV_FROB2379 void defaultOsMajorRevFrob(char *buf, int size)2380 {DEFAULT_OS_MAJOR_REV_FROB(buf,size)}2381 # else2382 void (*defaultOsMajorRevFrob)(char *buf, int size) = NULL;2383 # endif2384 # ifdef DEFAULT_OS_MINOR_REV_FROB2385 void defaultOsMinorRevFrob(char *buf, int size)2386 {DEFAULT_OS_MINOR_REV_FROB(buf,size)}2387 # else2388 void (*defaultOsMinorRevFrob)(char *buf, int size) = NULL;2389 # endif2390 # ifdef DEFAULT_OS_TEENY_REV_FROB2391 void defaultOsTeenyRevFrob(char *buf, int size)2392 {DEFAULT_OS_TEENY_REV_FROB(buf,size)}2393 # else2394 void (*defaultOsTeenyRevFrob)(char *buf, int size) = NULL;2395 # endif2396 # endif /* CROSSCOMPILE_CPP */2397 2398 #else /* else MAKEDEPEND */2399 #if !defined (CROSSCOMPILE) || defined (CROSSCOMPILE_CPP)2400 /*2401 * Step 7: predefs2402 * If your compiler and/or preprocessor define any specific symbols, add2403 * them to the the following table. The definition of struct symtab is2404 * in util/makedepend/def.h.2405 */2406 #undef DEF_EVALUATE2407 #undef DEF_STRINGIFY2408 #define DEF_EVALUATE(__x) #__x2409 #define DEF_STRINGIFY(_x) DEF_EVALUATE(_x)2410 struct symtab predefs[] = {2411 #ifdef apollo2412 {"apollo", "1"},2413 #endif2414 #if defined(clipper) || defined(__clipper__)2415 {"clipper", "1"},2416 {"__clipper__", "1"},2417 {"clix", "1"},2418 {"__clix__", "1"},2419 #endif2420 #ifdef ibm0322421 {"ibm032", "1"},2422 #endif2423 #ifdef ibm2424 {"ibm", "1"},2425 #endif2426 #ifdef aix2427 {"aix", "1"},2428 #endif2429 #ifdef sun2430 {"sun", "1"},2431 #endif2432 #ifdef sun22433 {"sun2", "1"},2434 #endif2435 #ifdef sun32436 {"sun3", "1"},2437 #endif2438 #ifdef sun42439 {"sun4", "1"},2440 #endif2441 #ifdef sparc2442 {"sparc", "1"},2443 #endif2444 #ifdef __sparc2445 {"__sparc", "1"},2446 #endif2447 #ifdef __sparcv92448 {"__sparcv9", "1"},2449 #endif2450 #ifdef __sparc__2451 {"__sparc__", "1"},2452 #endif2453 #ifdef __sparcv9__2454 {"__sparcv9__", "1"},2455 #endif2456 #ifdef hpux2457 {"hpux", "1"},2458 #endif2459 #ifdef __hpux2460 {"__hpux", "1"},2461 #endif2462 #ifdef __hp9000s8002463 {"__hp9000s800", "1"},2464 #endif2465 #ifdef __hp9000s7002466 {"__hp9000s700", "1"},2467 #endif2468 #ifdef vax2469 {"vax", "1"},2470 #endif2471 #ifdef VMS2472 {"VMS", "1"},2473 #endif2474 #ifdef cray2475 {"cray", "1"},2476 #endif2477 #ifdef CRAY2478 {"CRAY", "1"},2479 #endif2480 #ifdef _CRAY2481 {"_CRAY", "1"},2482 #endif2483 #ifdef att2484 {"att", "1"},2485 #endif2486 #ifdef mips2487 {"mips", "1"},2488 #endif2489 #ifdef __mips__2490 {"__mips__", "1"},2491 #endif2492 #ifdef ultrix2493 {"ultrix", "1"},2494 #endif2495 #ifdef stellar2496 {"stellar", "1"},2497 #endif2498 #ifdef mc680002499 {"mc68000", "1"},2500 #endif2501 #ifdef mc680202502 {"mc68020", "1"},2503 #endif2504 #ifdef __GNUC__2505 {"__GNUC__", DEF_STRINGIFY(__GNUC__)},2506 #endif2507 #ifdef __STRICT_ANSI__2508 {"__STRICT_ANSI__", "1"},2509 #endif2510 #ifdef __STDC__2511 {"__STDC__", DEF_STRINGIFY(__STDC__)},2512 #endif2513 #ifdef __HIGHC__2514 {"__HIGHC__", "1"},2515 #endif2516 #ifdef CMU2517 {"CMU", "1"},2518 #endif2519 #ifdef luna2520 {"luna", "1"},2521 #ifdef luna12522 {"luna1", "1"},2523 #endif2524 #ifdef luna22525 {"luna2", "1"},2526 #endif2527 #ifdef luna88k2528 {"luna88k", "1"},2529 #endif2530 #ifdef uniosb2531 {"uniosb", "1"},2532 #endif2533 #ifdef uniosu2534 {"uniosu", "1"},2535 #endif2536 #endif2537 #ifdef ieeep7542538 {"ieeep754", "1"},2539 #endif2540 #ifdef is68k2541 {"is68k", "1"},2542 #endif2543 #ifdef m68k2544 {"m68k", "1"},2545 #endif2546 #ifdef M68k2547 {"M68k", "1"},2548 #endif2549 #ifdef __m68k__2550 {"__m68k__", "1"},2551 #endif2552 #ifdef m88k2553 {"m88k", "1"},2554 #endif2555 #ifdef __m88k__2556 {"__m88k__", "1"},2557 #endif2558 #ifdef bsd432559 {"bsd43", "1"},2560 #endif2561 #ifdef hcx2562 {"hcx", "1"},2563 #endif2564 #ifdef sony2565 {"sony", "1"},2566 #ifdef SYSTYPE_SYSV2567 {"SYSTYPE_SYSV", "1"},2568 #endif2569 #ifdef _SYSTYPE_SYSV2570 {"_SYSTYPE_SYSV", "1"},2571 #endif2572 #endif2573 #ifdef __OSF__2574 {"__OSF__", "1"},2575 #endif2576 #ifdef __osf__2577 {"__osf__", "1"},2578 #endif2579 #ifdef __amiga__2580 {"__amiga__", "1"},2581 #endif2582 #ifdef __alpha2583 {"__alpha", "1"},2584 #endif2585 #ifdef __alpha__2586 {"__alpha__", "1"},2587 #endif2588 #ifdef __DECC2589 {"__DECC", "1"},2590 #endif2591 #ifdef __decc2592 {"__decc", "1"},2593 #endif2594 #ifdef __unix__2595 {"__unix__", "1"},2596 #endif2597 #ifdef __uxp__2598 {"__uxp__", "1"},2599 #endif2600 #ifdef __sxg__2601 {"__sxg__", "1"},2602 #endif2603 #ifdef _SEQUENT_2604 {"_SEQUENT_", "1"},2605 {"__STDC__", "1"},2606 #endif2607 #ifdef __bsdi__2608 {"__bsdi__", "1"},2609 #endif2610 #ifdef nec_ews_svr22611 {"nec_ews_svr2", "1"},2612 #endif2613 #ifdef nec_ews_svr42614 {"nec_ews_svr4", "1"},2615 #endif2616 #ifdef _nec_ews_svr42617 {"_nec_ews_svr4", "1"},2618 #endif2619 #ifdef _nec_up2620 {"_nec_up", "1"},2621 #endif2622 #ifdef SX2623 {"SX", "1"},2624 #endif2625 #ifdef nec2626 {"nec", "1"},2627 #endif2628 #ifdef _nec_ft2629 {"_nec_ft", "1"},2630 #endif2631 #ifdef PC_UX2632 {"PC_UX", "1"},2633 #endif2634 #ifdef sgi2635 {"sgi", "1"},2636 #endif2637 #ifdef __sgi2638 {"__sgi", "1"},2639 #endif2640 #ifdef _MIPS_FPSET2641 {"_MIPS_FPSET", DEF_STRINGIFY(_MIPS_FPSET)},2642 #endif2643 #ifdef _MIPS_ISA2644 {"_MIPS_ISA", DEF_STRINGIFY(_MIPS_ISA)},2645 #endif2646 #ifdef _MIPS_SIM2647 {"_MIPS_SIM", DEF_STRINGIFY(_MIPS_SIM)},2648 #endif2649 #ifdef _MIPS_SZINT2650 {"_MIPS_SZINT", DEF_STRINGIFY(_MIPS_SZINT)},2651 #endif2652 #ifdef _MIPS_SZLONG2653 {"_MIPS_SZLONG", DEF_STRINGIFY(_MIPS_SZLONG)},2654 #endif2655 #ifdef _MIPS_SZPTR2656 {"_MIPS_SZPTR", DEF_STRINGIFY(_MIPS_SZPTR)},2657 #endif2658 #ifdef __FreeBSD__2659 {"__FreeBSD__", "1"},2660 #endif2661 #ifdef __OpenBSD__2662 {"__OpenBSD__", "1"},2663 #endif2664 #ifdef __NetBSD__2665 {"__NetBSD__", "1"},2666 #endif2667 #ifdef __GNU__2668 {"__GNU__", "1"},2669 #endif2670 #ifdef __ELF__2671 {"__ELF__", "1"},2672 #endif2673 #ifdef __UNIXOS2__2674 {"__UNIXOS2__", "1"},2675 #endif2676 #if defined(__QNX__)2677 {"__QNX__", "1"},2678 #endif2679 #ifdef __QNXNTO__2680 {"__QNXNTO__", "1"},2681 #endif2682 # ifdef __powerpc__2683 {"__powerpc__", "1"},2684 # endif2685 # ifdef PowerMAX_OS2686 {"PowerMAX_OS", "1"},2687 # endif2688 # ifdef ia642689 {"ia64", "1"},2690 # endif2691 # ifdef __ia64__2692 {"__ia64__", "1"},2693 # endif2694 # if defined (AMD64) || defined (x86_64)2695 {"AMD64", "1"},2696 {"x86_64", "1"},2697 # endif2698 # if defined (__AMD64__) || defined (__x86_64__)2699 {"__AMD64__", "1"},2700 {"__x86_64__", "1"},2701 # endif2702 # ifdef __i3862703 {"__i386", "1"},2704 # endif2705 # ifdef __i386__2706 {"__i386__", "1"},2707 # endif2708 # ifdef __i486__2709 {"__i486__", "1"},2710 # endif2711 # ifdef __i586__2712 {"__i586__", "1"},2713 # endif2714 # ifdef __i686__2715 {"__i686__", "1"},2716 # endif2717 # ifdef __k6__2718 {"__k6__", "1"},2719 # endif2720 # ifdef i3862721 {"i386", "1"},2722 # endif2723 # ifdef i4862724 {"i486", "1"},2725 # endif2726 # ifdef i5862727 {"i586", "1"},2728 # endif2729 # ifdef i6862730 { "i686", "1"},2731 # endif2732 # ifdef k62733 {"k6", "1"},2734 # endif2735 # ifdef sparc2736 {"sparc", "1"},2737 # endif2738 # ifdef __sparc__2739 {"__sparc__", "1"},2740 # endif2741 # ifdef __s390__2742 {"__s390__", "1"},2743 # endif2744 # ifdef __sh__2745 {"__sh__", "1"},2746 # endif2747 # ifdef __sh3_2748 {"__sh3__", "1"},2749 # endif2750 # ifdef __SH3__2751 {"__SH3__", "1"},2752 # endif2753 # ifdef __SH4__2754 {"__SH4__", "1"},2755 # endif2756 # ifdef __SH4NOFPU__2757 {"__SH4NOFPU__", "1"},2758 # endif2759 #if defined(__ppc__)2760 {"__ppc__", "1"},2761 #endif2762 #if defined(__BIG_ENDIAN__)2763 {"__BIG_ENDIAN__", "1"},2764 #endif2765 #if defined(__LITTLE_ENDIAN__)2766 {"__LITTLE_ENDIAN__", "1"},2767 #endif2768 /* add any additional symbols before this line */2769 {NULL, NULL}2770 };2771 #undef DEF_EVALUATE2772 #undef DEF_STRINGIFY2773 #endif /* CROSSCOMPILE */2774 #endif /* MAKEDEPEND */2775 2776 # ifndef MAKEDEPEND2777 # if defined (CROSSCOMPILE_CPP)2778 # ifdef USE_CC_E2779 boolean crosscompile_use_cc_e = TRUE;2780 # ifdef DEFAULT_CC2781 char* crosscompile_cpp = DEFAULT_CC;2782 # else2783 char* crosscompile_cpp = "cc";2784 # endif2785 # else2786 boolean crosscompile_use_cc_e = FALSE;2787 # ifdef DEFAULT_CPP2788 char* crosscompile_cpp = DEFAULT_CPP;2789 # else2790 char* crosscompile_cpp = "cpp";2791 # endif2792 # endif2793 # ifdef FIXUP_CPP_WHITESPACE2794 boolean fixup_whitespace = TRUE;2795 # else2796 boolean fixup_whitespace = FALSE;2797 # endif2798 # ifdef REMOVE_CPP_LEADSPACE2799 boolean remove_cpp_leadspace = TRUE;2800 # else2801 boolean remove_cpp_leadspace = FALSE;2802 # endif2803 # ifdef INLINE_SYNTAX2804 boolean inline_syntax = TRUE;2805 # else2806 boolean inline_syntax = FALSE;2807 # endif2808 # ifdef MAGIC_MAKE_VARS2809 boolean magic_make_vars = TRUE;2810 # else2811 boolean magic_make_vars = FALSE;2812 # endif2813 2814 typedef enum {2815 unknown,2816 freeBSD,2817 netBSD,2818 LinuX,2819 emx,2820 win322821 } System;2822 2823 # ifdef linux2824 System sys = LinuX;2825 # elif defined __FreeBSD__2826 System sys = freebsd;2827 # elif defined __NetBSD__2828 System sys = netBSD;2829 # elif defined __EMX__2830 System sys = emx;2831 # elif defined WIN322832 System sys = win32;2833 # else2834 System sys = unknown;2835 # endif2836 2837 # if defined __GNUC__2838 int gnu_c = __GNUC__;2839 int gnu_c_minor = __GNUC_MINOR__;2840 # else2841 int gnu_c = 0;2842 int gnu_c_minor = -1;2843 # endif2844 # if defined linux2845 # include <features.h>2846 int glibc_major = __GLIBC__ + 4;2847 int glibc_minor = __GLIBC_MINOR__;2848 # else2849 int glibc_major = 0;2850 int glibc_minor = -1;2851 # endif2852 # endif /* !CROSSCOMPILE || CROSSCOMPILE_CPP */2853 2854 # endif /* MAKEDEPEND */2855 2856 #endif /* CCIMAKE */ -
makedepend.dsp
1 # Microsoft Developer Studio Project File - Name="makedepend" - Package Owner=<4> 2 # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 # ** DO NOT EDIT ** 4 5 # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 7 CFG=makedepend - Win32 Debug 8 !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 !MESSAGE use the Export Makefile command and run 10 !MESSAGE 11 !MESSAGE NMAKE /f "makedepend.mak". 12 !MESSAGE 13 !MESSAGE You can specify a configuration when running NMAKE 14 !MESSAGE by defining the macro CFG on the command line. For example: 15 !MESSAGE 16 !MESSAGE NMAKE /f "makedepend.mak" CFG="makedepend - Win32 Debug" 17 !MESSAGE 18 !MESSAGE Possible choices for configuration are: 19 !MESSAGE 20 !MESSAGE "makedepend - Win32 Release" (based on "Win32 (x86) Console Application") 21 !MESSAGE "makedepend - Win32 Debug" (based on "Win32 (x86) Console Application") 22 !MESSAGE 23 24 # Begin Project 25 # PROP AllowPerConfigDependencies 0 26 # PROP Scc_ProjName ""$/ALS2/tools/makedepend", XCGAAAAA" 27 # PROP Scc_LocalPath "." 28 CPP=cl.exe 29 RSC=rc.exe 30 31 !IF "$(CFG)" == "makedepend - Win32 Release" 32 33 # PROP BASE Use_MFC 0 34 # PROP BASE Use_Debug_Libraries 0 35 # PROP BASE Output_Dir "Release" 36 # PROP BASE Intermediate_Dir "Release" 37 # PROP BASE Target_Dir "" 38 # PROP Use_MFC 0 39 # PROP Use_Debug_Libraries 0 40 # PROP Output_Dir "Release" 41 # PROP Intermediate_Dir "Release" 42 # PROP Target_Dir "" 43 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 44 # ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D STANDALONE=1 /D OBJSUFFIX=\".obj\" /YX /FD /c 45 # ADD BASE RSC /l 0x409 /d "NDEBUG" 46 # ADD RSC /l 0x409 /d "NDEBUG" 47 BSC32=bscmake.exe 48 # ADD BASE BSC32 /nologo 49 # ADD BSC32 /nologo 50 LINK32=link.exe 51 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 52 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 53 54 !ELSEIF "$(CFG)" == "makedepend - Win32 Debug" 55 56 # PROP BASE Use_MFC 0 57 # PROP BASE Use_Debug_Libraries 1 58 # PROP BASE Output_Dir "makedepend___Win32_Debug" 59 # PROP BASE Intermediate_Dir "makedepend___Win32_Debug" 60 # PROP BASE Target_Dir "" 61 # PROP Use_MFC 0 62 # PROP Use_Debug_Libraries 1 63 # PROP Output_Dir "makedepend___Win32_Debug" 64 # PROP Intermediate_Dir "makedepend___Win32_Debug" 65 # PROP Target_Dir "" 66 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 67 # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D STANDALONE=1 /D OBJSUFFIX=\".obj\" /YX /FD /GZ /c 68 # ADD BASE RSC /l 0x409 /d "_DEBUG" 69 # ADD RSC /l 0x409 /d "_DEBUG" 70 BSC32=bscmake.exe 71 # ADD BASE BSC32 /nologo 72 # ADD BSC32 /nologo 73 LINK32=link.exe 74 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 75 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 76 77 !ENDIF 78 79 # Begin Target 80 81 # Name "makedepend - Win32 Release" 82 # Name "makedepend - Win32 Debug" 83 # Begin Group "Source Files" 84 85 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 86 # Begin Source File 87 88 SOURCE=.\cppsetup.c 89 # End Source File 90 # Begin Source File 91 92 SOURCE=.\ifparser.c 93 # End Source File 94 # Begin Source File 95 96 SOURCE=.\include.c 97 # End Source File 98 # Begin Source File 99 100 SOURCE=.\main.c 101 # End Source File 102 # Begin Source File 103 104 SOURCE=.\parse.c 105 # End Source File 106 # Begin Source File 107 108 SOURCE=.\pr.c 109 # End Source File 110 # End Group 111 # Begin Group "Header Files" 112 113 # PROP Default_Filter "h;hpp;hxx;hm;inl" 114 # Begin Source File 115 116 SOURCE=.\def.h 117 # End Source File 118 # Begin Source File 119 120 SOURCE=.\ifparser.h 121 # End Source File 122 # Begin Source File 123 124 SOURCE=.\imakemdep.h 125 # End Source File 126 # End Group 127 # Begin Group "Resource Files" 128 129 # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 130 # End Group 131 # End Target 132 # End Project 133 # Microsoft Developer Studio Project File - Name="makedepend" - Package Owner=<4> 134 # Microsoft Developer Studio Generated Build File, Format Version 6.00 135 # ** DO NOT EDIT ** 136 137 # TARGTYPE "Win32 (x86) Console Application" 0x0103 138 139 CFG=makedepend - Win32 Debug 140 !MESSAGE This is not a valid makefile. To build this project using NMAKE, 141 !MESSAGE use the Export Makefile command and run 142 !MESSAGE 143 !MESSAGE NMAKE /f "makedepend.mak". 144 !MESSAGE 145 !MESSAGE You can specify a configuration when running NMAKE 146 !MESSAGE by defining the macro CFG on the command line. For example: 147 !MESSAGE 148 !MESSAGE NMAKE /f "makedepend.mak" CFG="makedepend - Win32 Debug" 149 !MESSAGE 150 !MESSAGE Possible choices for configuration are: 151 !MESSAGE 152 !MESSAGE "makedepend - Win32 Release" (based on "Win32 (x86) Console Application") 153 !MESSAGE "makedepend - Win32 Debug" (based on "Win32 (x86) Console Application") 154 !MESSAGE 155 156 # Begin Project 157 # PROP AllowPerConfigDependencies 0 158 # PROP Scc_ProjName ""$/ALS2/tools/makedepend", XCGAAAAA" 159 # PROP Scc_LocalPath "." 160 CPP=cl.exe 161 RSC=rc.exe 162 163 !IF "$(CFG)" == "makedepend - Win32 Release" 164 165 # PROP BASE Use_MFC 0 166 # PROP BASE Use_Debug_Libraries 0 167 # PROP BASE Output_Dir "Release" 168 # PROP BASE Intermediate_Dir "Release" 169 # PROP BASE Target_Dir "" 170 # PROP Use_MFC 0 171 # PROP Use_Debug_Libraries 0 172 # PROP Output_Dir "Release" 173 # PROP Intermediate_Dir "Release" 174 # PROP Target_Dir "" 175 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 176 # ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D STANDALONE=1 /D OBJSUFFIX=\".obj\" /YX /FD /c 177 # ADD BASE RSC /l 0x409 /d "NDEBUG" 178 # ADD RSC /l 0x409 /d "NDEBUG" 179 BSC32=bscmake.exe 180 # ADD BASE BSC32 /nologo 181 # ADD BSC32 /nologo 182 LINK32=link.exe 183 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 184 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 185 186 !ELSEIF "$(CFG)" == "makedepend - Win32 Debug" 187 188 # PROP BASE Use_MFC 0 189 # PROP BASE Use_Debug_Libraries 1 190 # PROP BASE Output_Dir "makedepend___Win32_Debug" 191 # PROP BASE Intermediate_Dir "makedepend___Win32_Debug" 192 # PROP BASE Target_Dir "" 193 # PROP Use_MFC 0 194 # PROP Use_Debug_Libraries 1 195 # PROP Output_Dir "makedepend___Win32_Debug" 196 # PROP Intermediate_Dir "makedepend___Win32_Debug" 197 # PROP Target_Dir "" 198 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 199 # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D STANDALONE=1 /D OBJSUFFIX=\".obj\" /YX /FD /GZ /c 200 # ADD BASE RSC /l 0x409 /d "_DEBUG" 201 # ADD RSC /l 0x409 /d "_DEBUG" 202 BSC32=bscmake.exe 203 # ADD BASE BSC32 /nologo 204 # ADD BSC32 /nologo 205 LINK32=link.exe 206 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 207 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 208 209 !ENDIF 210 211 # Begin Target 212 213 # Name "makedepend - Win32 Release" 214 # Name "makedepend - Win32 Debug" 215 # Begin Group "Source Files" 216 217 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 218 # Begin Source File 219 220 SOURCE=.\cppsetup.c 221 # End Source File 222 # Begin Source File 223 224 SOURCE=.\ifparser.c 225 # End Source File 226 # Begin Source File 227 228 SOURCE=.\include.c 229 # End Source File 230 # Begin Source File 231 232 SOURCE=.\main.c 233 # End Source File 234 # Begin Source File 235 236 SOURCE=.\parse.c 237 # End Source File 238 # Begin Source File 239 240 SOURCE=.\pr.c 241 # End Source File 242 # End Group 243 # Begin Group "Header Files" 244 245 # PROP Default_Filter "h;hpp;hxx;hm;inl" 246 # Begin Source File 247 248 SOURCE=.\def.h 249 # End Source File 250 # Begin Source File 251 252 SOURCE=.\ifparser.h 253 # End Source File 254 # Begin Source File 255 256 SOURCE=.\imakemdep.h 257 # End Source File 258 # End Group 259 # Begin Group "Resource Files" 260 261 # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 262 # End Group 263 # End Target 264 # End Project 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 -
pr.c
+# Microsoft Developer Studio Project File - Name="makedepend" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=makedepend - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "makedepend.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "makedepend.mak" CFG="makedepend - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "makedepend - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "makedepend - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/ALS2/tools/makedepend", XCGAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "makedepend - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D STANDALONE=1 /D OBJSUFFIX=\".obj\" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "makedepend - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "makedepend___Win32_Debug" +# PROP BASE Intermediate_Dir "makedepend___Win32_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "makedepend___Win32_Debug" +# PROP Intermediate_Dir "makedepend___Win32_Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D STANDALONE=1 /D OBJSUFFIX=\".obj\" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "makedepend - Win32 Release" +# Name "makedepend - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\cppsetup.c +# End Source File +# Begin Source File + +SOURCE=.\ifparser.c +# End Source File +# Begin Source File + +SOURCE=.\include.c +# End Source File +# Begin Source File + +SOURCE=.\main.c +# End Source File +# Begin Source File + +SOURCE=.\parse.c +# End Source File +# Begin Source File + +SOURCE=.\pr.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\def.h +# End Source File +# Begin Source File + +SOURCE=.\ifparser.h +# End Source File +# Begin Source File + +SOURCE=.\imakemdep.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project +# Microsoft Developer Studio Project File - Name="makedepend" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=makedepend - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "makedepend.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "makedepend.mak" CFG="makedepend - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "makedepend - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "makedepend - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName ""$/ALS2/tools/makedepend", XCGAAAAA" +# PROP Scc_LocalPath "." +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "makedepend - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D STANDALONE=1 /D OBJSUFFIX=\".obj\" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "makedepend - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "makedepend___Win32_Debug" +# PROP BASE Intermediate_Dir "makedepend___Win32_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "makedepend___Win32_Debug" +# PROP Intermediate_Dir "makedepend___Win32_Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D STANDALONE=1 /D OBJSUFFIX=\".obj\" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "makedepend - Win32 Release" +# Name "makedepend - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\cppsetup.c +# End Source File +# Begin Source File + +SOURCE=.\ifparser.c +# End Source File +# Begin Source File + +SOURCE=.\include.c +# End Source File +# Begin Source File + +SOURCE=.\main.c +# End Source File +# Begin Source File + +SOURCE=.\parse.c +# End Source File +# Begin Source File + +SOURCE=.\pr.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\def.h +# End Source File +# Begin Source File + +SOURCE=.\ifparser.h +# End Source File +# Begin Source File + +SOURCE=.\imakemdep.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project
122 122 for (i=0; i<head->i_listlen; i++) 123 123 recursive_pr_include(head->i_list[ i ], file, base); 124 124 } 125 /*126 127 Copyright (c) 1993, 1994, 1998 The Open Group128 129 Permission to use, copy, modify, distribute, and sell this software and its130 documentation for any purpose is hereby granted without fee, provided that131 the above copyright notice appear in all copies and that both that132 copyright notice and this permission notice appear in supporting133 documentation.134 135 The above copyright notice and this permission notice shall be included in136 all copies or substantial portions of the Software.137 138 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR139 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,140 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE141 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN142 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN143 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.144 145 Except as contained in this notice, the name of The Open Group shall not be146 used in advertising or otherwise to promote the sale, use or other dealings147 in this Software without prior written authorization from The Open Group.148 149 */150 /* $Header: /code/makedepend/pr.c,v 1.3 2005/03/03 18:13:08 doj Exp $ */151 152 #include "def.h"153 154 extern struct inclist inclist[ MAXFILES ],155 *inclistp;156 extern char *objprefix;157 extern char *objsuffix;158 extern int width;159 extern boolean printed;160 extern boolean verbose;161 extern boolean show_where_not;162 163 void164 add_include(struct filepointer *filep, struct inclist *file,165 struct inclist *file_red, char *include, int type,166 boolean failOK)167 {168 register struct inclist *newfile;169 register struct filepointer *content;170 171 /*172 * First decide what the pathname of this include file really is.173 */174 newfile = inc_path(file->i_file, include, type);175 if (newfile == NULL) {176 if (failOK)177 return;178 if (file != file_red)179 warning("%s (reading %s, line %d): ",180 file_red->i_file, file->i_file, filep->f_line);181 else182 warning("%s, line %d: ", file->i_file, filep->f_line);183 warning1("cannot find include file \"%s\"\n", include);184 show_where_not = TRUE;185 newfile = inc_path(file->i_file, include, type);186 show_where_not = FALSE;187 }188 189 if (newfile) {190 included_by(file, newfile);191 if (!(newfile->i_flags & SEARCHED)) {192 newfile->i_flags |= SEARCHED;193 content = getfile(newfile->i_file);194 find_includes(content, newfile, file_red, 0, failOK);195 freefile(content);196 }197 }198 }199 200 static void201 pr(struct inclist *ip, char *file, char *base)202 {203 static char *lastfile;204 static int current_len;205 register int len, i;206 char buf[ BUFSIZ ];207 208 printed = TRUE;209 len = strlen(ip->i_file)+1;210 if (current_len + len > width || file != lastfile) {211 lastfile = file;212 /* Added quotes here, as i_file may have spaces in the paths under Win32 */213 sprintf(buf, "\n%s%s%s: \"%s\"", objprefix, base, objsuffix,214 ip->i_file);215 len = current_len = strlen(buf);216 }217 else {218 buf[0] = ' ';219 strcpy(buf+1, ip->i_file);220 current_len += len;221 }222 fwrite(buf, len, 1, stdout);223 224 /*225 * If verbose is set, then print out what this file includes.226 */227 if (! verbose || ip->i_list == NULL || ip->i_flags & NOTIFIED)228 return;229 ip->i_flags |= NOTIFIED;230 lastfile = NULL;231 printf("\n# %s includes:", ip->i_file);232 for (i=0; i<ip->i_listlen; i++)233 printf("\n#\t%s", ip->i_list[ i ]->i_incstring);234 }235 236 void237 recursive_pr_include(struct inclist *head, char *file, char *base)238 {239 int i;240 241 if (head->i_flags & MARKED)242 return;243 head->i_flags |= MARKED;244 if (head->i_file != file)245 pr(head, file, base);246 for (i=0; i<head->i_listlen; i++)247 recursive_pr_include(head->i_list[ i ], file, base);248 } -
cppsetup.c
230 230 } 231 231 #endif /* CPP */ 232 232 233 /*234 235 Copyright (c) 1993, 1994, 1998 The Open Group236 237 Permission to use, copy, modify, distribute, and sell this software and its238 documentation for any purpose is hereby granted without fee, provided that239 the above copyright notice appear in all copies and that both that240 copyright notice and this permission notice appear in supporting241 documentation.242 243 The above copyright notice and this permission notice shall be included in244 all copies or substantial portions of the Software.245 246 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR247 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,248 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE249 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN250 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN251 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.252 253 Except as contained in this notice, the name of The Open Group shall not be254 used in advertising or otherwise to promote the sale, use or other dealings255 in this Software without prior written authorization from The Open Group.256 257 */258 /* $Header: /code/makedepend/cppsetup.c,v 1.2 2004/04/20 19:50:26 doj Exp $ */259 260 #include "def.h"261 262 #ifdef CPP263 /*264 * This file is strictly for the sake of cpy.y and yylex.c (if265 * you indeed have the source for cpp).266 */267 #define IB 1268 #define SB 2269 #define NB 4270 #define CB 8271 #define QB 16272 #define WB 32273 #define SALT '#'274 #if defined(pdp11) || defined(vax) || defined(ns16000) || defined(mc68000) || defined(ibm032)275 #define COFF 128276 #else277 #define COFF 0278 #endif279 /*280 * These variables used by cpy.y and yylex.c281 */282 extern char *outp, *inp, *newp, *pend;283 extern char *ptrtab;284 extern char fastab[];285 extern char slotab[];286 287 /*288 * cppsetup289 */290 struct filepointer *currentfile;291 struct inclist *currentinc;292 293 int294 cppsetup(char *line, struct filepointer *filep, struct inclist *inc)295 {296 char *p, savec;297 static boolean setupdone = FALSE;298 boolean value;299 300 if (!setupdone) {301 cpp_varsetup();302 setupdone = TRUE;303 }304 305 currentfile = filep;306 currentinc = inc;307 inp = newp = line;308 for (p=newp; *p; p++)309 ;310 311 /*312 * put a newline back on the end, and set up pend, etc.313 */314 *p++ = '\n';315 savec = *p;316 *p = '\0';317 pend = p;318 319 ptrtab = slotab+COFF;320 *--inp = SALT;321 outp=inp;322 value = yyparse();323 *p = savec;324 return(value);325 }326 327 struct symtab **lookup(symbol)328 char *symbol;329 {330 static struct symtab *undefined;331 struct symtab **sp;332 333 sp = isdefined(symbol, currentinc, NULL);334 if (sp == NULL) {335 sp = &undefined;336 (*sp)->s_value = NULL;337 }338 return (sp);339 }340 341 pperror(tag, x0,x1,x2,x3,x4)342 int tag,x0,x1,x2,x3,x4;343 {344 warning("\"%s\", line %d: ", currentinc->i_file, currentfile->f_line);345 warning(x0,x1,x2,x3,x4);346 }347 348 349 yyerror(s)350 register char *s;351 {352 fatalerr("Fatal error: %s\n", s);353 }354 #else /* not CPP */355 356 #include "ifparser.h"357 struct _parse_data {358 struct filepointer *filep;359 struct inclist *inc;360 char *filename;361 const char *line;362 };363 364 static const char *365 my_if_errors (IfParser *ip, const char *cp, const char *expecting)366 {367 struct _parse_data *pd = (struct _parse_data *) ip->data;368 int lineno = pd->filep->f_line;369 char *filename = pd->filename;370 char prefix[300];371 int prefixlen;372 int i;373 374 sprintf (prefix, "\"%s\":%d", filename, lineno);375 prefixlen = strlen(prefix);376 fprintf (stderr, "%s: %s", prefix, pd->line);377 i = cp - pd->line;378 if (i > 0 && pd->line[i-1] != '\n') {379 putc ('\n', stderr);380 }381 for (i += prefixlen + 3; i > 0; i--) {382 putc (' ', stderr);383 }384 fprintf (stderr, "^--- expecting %s\n", expecting);385 return NULL;386 }387 388 389 #define MAXNAMELEN 256390 391 static struct symtab **392 lookup_variable (IfParser *ip, const char *var, int len)393 {394 char tmpbuf[MAXNAMELEN + 1];395 struct _parse_data *pd = (struct _parse_data *) ip->data;396 397 if (len > MAXNAMELEN)398 return 0;399 400 strncpy (tmpbuf, var, len);401 tmpbuf[len] = '\0';402 return isdefined (tmpbuf, pd->inc, NULL);403 }404 405 406 static int407 my_eval_defined (IfParser *ip, const char *var, int len)408 {409 if (lookup_variable (ip, var, len))410 return 1;411 else412 return 0;413 }414 415 #define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')416 417 static long418 my_eval_variable (IfParser *ip, const char *var, int len)419 {420 long val;421 struct symtab **s;422 423 s = lookup_variable (ip, var, len);424 if (!s)425 return 0;426 do {427 var = (*s)->s_value;428 if (!isvarfirstletter(*var) || !strcmp((*s)->s_name, var))429 break;430 s = lookup_variable (ip, var, strlen(var));431 } while (s);432 433 var = ParseIfExpression(ip, var, &val);434 if (var && *var) debug(4, ("extraneous: '%s'\n", var));435 return val;436 }437 438 int439 cppsetup(char *filename,440 char *line,441 struct filepointer *filep,442 struct inclist *inc)443 {444 IfParser ip;445 struct _parse_data pd;446 long val = 0;447 448 pd.filep = filep;449 pd.inc = inc;450 pd.line = line;451 pd.filename = filename;452 ip.funcs.handle_error = my_if_errors;453 ip.funcs.eval_defined = my_eval_defined;454 ip.funcs.eval_variable = my_eval_variable;455 ip.data = (char *) &pd;456 457 (void) ParseIfExpression (&ip, line, &val);458 if (val)459 return IF;460 else461 return IFFALSE;462 }463 #endif /* CPP */464 -
def.h
182 182 extern void fatalerr(char *, ...); 183 183 extern void warning(char *, ...); 184 184 extern void warning1(char *, ...); 185 /*186 187 Copyright (c) 1993, 1994, 1998 The Open Group.188 189 Permission to use, copy, modify, distribute, and sell this software and its190 documentation for any purpose is hereby granted without fee, provided that191 the above copyright notice appear in all copies and that both that192 copyright notice and this permission notice appear in supporting193 documentation.194 195 The above copyright notice and this permission notice shall be included in196 all copies or substantial portions of the Software.197 198 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR199 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,200 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE201 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN202 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN203 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.204 205 Except as contained in this notice, the name of The Open Group shall not be206 used in advertising or otherwise to promote the sale, use or other dealings207 in this Software without prior written authorization from The Open Group.208 209 */210 211 /* $Header: /code/makedepend/def.h,v 1.2 2004/04/20 19:50:26 doj Exp $ */212 213 #ifndef STANDALONE214 #include "Xos.h"215 #include "Xfuncproto.h"216 #endif217 #include <stdlib.h>218 #include <stdio.h>219 #include <string.h>220 #include <ctype.h>221 #if 0222 #ifndef X_NOT_POSIX223 #ifndef _POSIX_SOURCE224 #define _POSIX_SOURCE225 #endif226 #endif227 #endif228 #include <sys/types.h>229 #include <fcntl.h>230 #include <sys/stat.h>231 232 #define MAXDEFINES 512233 #define MAXFILES 1024234 #define MAXINCFILES 128 /* "-include" files */235 #define MAXDIRS 64236 #define SYMTABINC 10 /* must be > 1 for define() to work right */237 #define TRUE 1238 #define FALSE 0239 240 /* the following must match the directives table in main.c */241 #define IF 0242 #define IFDEF 1243 #define IFNDEF 2244 #define ELSE 3245 #define ENDIF 4246 #define DEFINE 5247 #define UNDEF 6248 #define INCLUDE 7249 #define LINE 8250 #define PRAGMA 9251 #define ERROR 10252 #define IDENT 11253 #define SCCS 12254 #define ELIF 13255 #define EJECT 14256 #define WARNING 15257 #define INCLUDENEXT 16258 #define IFFALSE 17 /* pseudo value --- never matched */259 #define ELIFFALSE 18 /* pseudo value --- never matched */260 #define INCLUDEDOT 19 /* pseudo value --- never matched */261 #define IFGUESSFALSE 20 /* pseudo value --- never matched */262 #define ELIFGUESSFALSE 21 /* pseudo value --- never matched */263 #define INCLUDENEXTDOT 22 /* pseudo value --- never matched */264 265 #ifdef DEBUG266 extern int _debugmask;267 /*268 * debug levels are:269 *270 * 0 show ifn*(def)*,endif271 * 1 trace defined/!defined272 * 2 show #include273 * 3 show #include SYMBOL274 * 4-6 unused275 */276 #define debug(level,arg) { if (_debugmask & (1 << level)) warning arg; }277 #else278 #define debug(level,arg) /**/279 #endif /* DEBUG */280 281 typedef unsigned char boolean;282 283 struct symtab {284 char *s_name;285 char *s_value;286 };287 288 /* possible i_flag */289 #define DEFCHECKED (1<<0) /* whether defines have been checked */290 #define NOTIFIED (1<<1) /* whether we have revealed includes */291 #define MARKED (1<<2) /* whether it's in the makefile */292 #define SEARCHED (1<<3) /* whether we have read this */293 #define FINISHED (1<<4) /* whether we are done reading this */294 #define INCLUDED_SYM (1<<5) /* whether #include SYMBOL was found295 Can't use i_list if TRUE */296 struct inclist {297 char *i_incstring; /* string from #include line */298 char *i_file; /* path name of the include file */299 struct inclist **i_list; /* list of files it itself includes */300 int i_listlen; /* length of i_list */301 struct symtab **i_defs; /* symbol table for this file and its302 children when merged */303 int i_ndefs; /* current # defines */304 boolean *i_merged; /* whether we have merged child305 defines */306 unsigned char i_flags;307 };308 309 struct filepointer {310 char *f_name;311 char *f_p;312 char *f_base;313 char *f_end;314 long f_len;315 long f_line;316 long cmdinc_count;317 char **cmdinc_list;318 long cmdinc_line;319 };320 321 #include <stdlib.h>322 #if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */323 char *malloc(), *realloc();324 #endif /* macII */325 326 char *copy(char *str);327 int match(char *str, char **list);328 char *base_name(char *file);329 char *getnextline(struct filepointer *fp);330 struct symtab **slookup(char *symbol, struct inclist *file);331 struct symtab **isdefined(char *symbol, struct inclist *file,332 struct inclist **srcfile);333 struct symtab **fdefined(char *symbol, struct inclist *file,334 struct inclist **srcfile);335 struct filepointer *getfile(char *file);336 void included_by(struct inclist *ip,337 struct inclist *newfile);338 struct inclist *newinclude(char *newfile, char *incstring);339 void inc_clean (void);340 struct inclist *inc_path(char *file, char *include, int type);341 342 void freefile(struct filepointer *fp);343 344 void define2(char *name, char *val, struct inclist *file);345 void define(char *def, struct inclist *file);346 void undefine(char *symbol, struct inclist *file);347 int find_includes(struct filepointer *filep,348 struct inclist *file,349 struct inclist *file_red,350 int recursion, boolean failOK);351 352 void recursive_pr_include(struct inclist *head,353 char *file, char *base);354 void add_include(struct filepointer *filep,355 struct inclist *file,356 struct inclist *file_red,357 char *include, int type,358 boolean failOK);359 360 int cppsetup(char *filename,361 char *line,362 struct filepointer *filep,363 struct inclist *inc);364 365 366 extern void fatalerr(char *, ...);367 extern void warning(char *, ...);368 extern void warning1(char *, ...); -
include.c
339 339 340 340 return NULL; 341 341 } 342 /*343 344 Copyright (c) 1993, 1994, 1998 The Open Group345 346 Permission to use, copy, modify, distribute, and sell this software and its347 documentation for any purpose is hereby granted without fee, provided that348 the above copyright notice appear in all copies and that both that349 copyright notice and this permission notice appear in supporting350 documentation.351 352 The above copyright notice and this permission notice shall be included in353 all copies or substantial portions of the Software.354 355 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR356 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,357 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE358 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN359 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN360 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.361 362 Except as contained in this notice, the name of The Open Group shall not be363 used in advertising or otherwise to promote the sale, use or other dealings364 in this Software without prior written authorization from The Open Group.365 366 */367 /* $Header: /code/makedepend/include.c,v 1.3 2005/03/03 18:12:01 doj Exp $ */368 369 370 #include "def.h"371 372 extern struct inclist inclist[ MAXFILES ],373 *inclistp, *inclistnext;374 extern char *includedirs[ ],375 **includedirsnext;376 extern char *notdotdot[ ];377 extern boolean show_where_not;378 extern boolean warn_multiple;379 380 static boolean381 isdot(char *p)382 {383 if(p && *p++ == '.' && *p++ == '\0')384 return(TRUE);385 return(FALSE);386 }387 388 static boolean389 isdotdot(char *p)390 {391 if(p && *p++ == '.' && *p++ == '.' && *p++ == '\0')392 return(TRUE);393 return(FALSE);394 }395 396 static boolean397 issymbolic(char *dir, char *component)398 {399 #ifdef S_IFLNK400 struct stat st;401 char buf[ BUFSIZ ], **pp;402 403 sprintf(buf, "%s%s%s", dir, *dir ? "/" : "", component);404 for (pp=notdotdot; *pp; pp++)405 if (strcmp(*pp, buf) == 0)406 return (TRUE);407 if (lstat(buf, &st) == 0408 && (st.st_mode & S_IFMT) == S_IFLNK) {409 *pp++ = copy(buf);410 if (pp >= ¬dotdot[ MAXDIRS ])411 fatalerr("out of .. dirs, increase MAXDIRS\n");412 return(TRUE);413 }414 #endif415 return(FALSE);416 }417 418 /*419 * Occasionally, pathnames are created that look like .../x/../y420 * Any of the 'x/..' sequences within the name can be eliminated.421 * (but only if 'x' is not a symbolic link!!)422 */423 static void424 remove_dotdot(char *path)425 {426 register char *end, *from, *to, **cp;427 char *components[ MAXFILES ],428 newpath[ BUFSIZ ];429 boolean component_copied;430 431 /*432 * slice path up into components.433 */434 to = newpath;435 if (*path == '/')436 *to++ = '/';437 #ifdef WIN32438 if (*path == '\\')439 *to++ = '\\';440 #endif441 *to = '\0';442 cp = components;443 for (from=end=path; *end; end++)444 {445 if (*end == '/') {446 while (*end == '/')447 *end++ = '\0';448 if (*from)449 *cp++ = from;450 from = end;451 }452 #ifdef WIN32453 if (*end == '\\') {454 while (*end == '\\')455 *end++ = '\0';456 if (*from)457 *cp++ = from;458 from = end;459 }460 #endif461 }462 *cp++ = from;463 *cp = NULL;464 465 /*466 * Recursively remove all 'x/..' component pairs.467 */468 cp = components;469 while(*cp) {470 if (!isdot(*cp) && !isdotdot(*cp) && isdotdot(*(cp+1))471 && !issymbolic(newpath, *cp))472 {473 char **fp = cp + 2;474 char **tp = cp;475 476 do477 *tp++ = *fp; /* move all the pointers down */478 while (*fp++);479 if (cp != components)480 cp--; /* go back and check for nested ".." */481 } else {482 cp++;483 }484 }485 /*486 * Concatenate the remaining path elements.487 */488 cp = components;489 component_copied = FALSE;490 while(*cp) {491 if (component_copied)492 *to++ = '/';493 component_copied = TRUE;494 for (from = *cp; *from; )495 *to++ = *from++;496 *to = '\0';497 cp++;498 }499 *to++ = '\0';500 501 /*502 * copy the reconstituted path back to our pointer.503 */504 strcpy(path, newpath);505 }506 507 /*508 * Add an include file to the list of those included by 'file'.509 */510 struct inclist *511 newinclude(char *newfile, char *incstring)512 {513 register struct inclist *ip;514 515 /*516 * First, put this file on the global list of include files.517 */518 ip = inclistp++;519 if (inclistp == inclist + MAXFILES - 1)520 fatalerr("out of space: increase MAXFILES\n");521 ip->i_file = copy(newfile);522 523 if (incstring == NULL)524 ip->i_incstring = ip->i_file;525 else526 ip->i_incstring = copy(incstring);527 528 inclistnext = inclistp;529 return(ip);530 }531 532 void533 included_by(struct inclist *ip, struct inclist *newfile)534 {535 register int i;536 537 if (ip == NULL)538 return;539 /*540 * Put this include file (newfile) on the list of files included541 * by 'file'. If 'file' is NULL, then it is not an include542 * file itself (i.e. was probably mentioned on the command line).543 * If it is already on the list, don't stick it on again.544 */545 if (ip->i_list == NULL) {546 ip->i_list = (struct inclist **)547 malloc(sizeof(struct inclist *) * ++ip->i_listlen);548 ip->i_merged = (boolean *)549 malloc(sizeof(boolean) * ip->i_listlen);550 } else {551 for (i=0; i<ip->i_listlen; i++)552 if (ip->i_list[ i ] == newfile) {553 i = strlen(newfile->i_file);554 if (!(ip->i_flags & INCLUDED_SYM) &&555 !(i > 2 &&556 newfile->i_file[i-1] == 'c' &&557 newfile->i_file[i-2] == '.'))558 {559 /* only bitch if ip has */560 /* no #include SYMBOL lines */561 /* and is not a .c file */562 if (warn_multiple)563 {564 warning("%s includes %s more than once!\n",565 ip->i_file, newfile->i_file);566 warning1("Already have\n");567 for (i=0; i<ip->i_listlen; i++)568 warning1("\t%s\n", ip->i_list[i]->i_file);569 }570 }571 return;572 }573 ip->i_list = (struct inclist **) realloc(ip->i_list,574 sizeof(struct inclist *) * ++ip->i_listlen);575 ip->i_merged = (boolean *)576 realloc(ip->i_merged, sizeof(boolean) * ip->i_listlen);577 }578 ip->i_list[ ip->i_listlen-1 ] = newfile;579 ip->i_merged[ ip->i_listlen-1 ] = FALSE;580 }581 582 void583 inc_clean (void)584 {585 register struct inclist *ip;586 587 for (ip = inclist; ip < inclistp; ip++) {588 ip->i_flags &= ~MARKED;589 }590 }591 592 struct inclist *593 inc_path(char *file, char *include, int type)594 {595 static char path[ BUFSIZ ];596 register char **pp, *p;597 register struct inclist *ip;598 struct stat st;599 600 /*601 * Check all previously found include files for a path that602 * has already been expanded.603 */604 if ((type == INCLUDE) || (type == INCLUDEDOT))605 inclistnext = inclist;606 ip = inclistnext;607 608 for (; ip->i_file; ip++) {609 if ((strcmp(ip->i_incstring, include) == 0) &&610 !(ip->i_flags & INCLUDED_SYM)) {611 inclistnext = ip + 1;612 return ip;613 }614 }615 616 if (inclistnext == inclist) {617 /*618 * If the path was surrounded by "" or is an absolute path,619 * then check the exact path provided.620 */621 if ((type == INCLUDEDOT) ||622 (type == INCLUDENEXTDOT) ||623 (*include == '/')624 #ifdef WIN32625 || (*include == '\\')626 #endif627 ) {628 if (stat(include, &st) == 0)629 return newinclude(include, include);630 if (show_where_not)631 warning1("\tnot in %s\n", include);632 }633 634 /*635 * If the path was surrounded by "" see if this include file is636 * in the directory of the file being parsed.637 */638 if ((type == INCLUDEDOT) || (type == INCLUDENEXTDOT)) {639 for (p=file+strlen(file); p>file; p--)640 if (*p == '/'641 #ifdef WIN32642 || *p == '\\'643 #endif644 )645 646 break;647 if (p == file) {648 strcpy(path, include);649 } else {650 strncpy(path, file, (p-file) + 1);651 path[ (p-file) + 1 ] = '\0';652 strcpy(path + (p-file) + 1, include);653 }654 remove_dotdot(path);655 if (stat(path, &st) == 0)656 return newinclude(path, include);657 if (show_where_not)658 warning1("\tnot in %s\n", path);659 }660 }661 662 /*663 * Check the include directories specified. Standard include dirs664 * should be at the end.665 */666 if ((type == INCLUDE) || (type == INCLUDEDOT))667 includedirsnext = includedirs;668 pp = includedirsnext;669 670 for (; *pp; pp++) {671 sprintf(path, "%s/%s", *pp, include);672 remove_dotdot(path);673 if (stat(path, &st) == 0) {674 includedirsnext = pp + 1;675 return newinclude(path, include);676 }677 if (show_where_not)678 warning1("\tnot in %s\n", path);679 }680 681 return NULL;682 } -
main.c
910 910 vfprintf(stderr, msg, args); 911 911 va_end(args); 912 912 } 913 /*914 915 Copyright (c) 1993, 1994, 1998 The Open Group916 917 Permission to use, copy, modify, distribute, and sell this software and its918 documentation for any purpose is hereby granted without fee, provided that919 the above copyright notice appear in all copies and that both that920 copyright notice and this permission notice appear in supporting921 documentation.922 923 The above copyright notice and this permission notice shall be included in924 all copies or substantial portions of the Software.925 926 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR927 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,928 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE929 THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN930 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN931 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.932 933 Except as contained in this notice, the name of The Open Group shall not be934 used in advertising or otherwise to promote the sale, use or other dealings935 in this Software without prior written authorization from The Open Group.936 937 */938 /* $Header: /code/makedepend/main.c,v 1.3 2005/03/03 18:13:08 doj Exp $ */939 940 /* modified for standalone and MS-Windows compilation by Dirk Jagdmann <doj@cubic.org> 2004-04-20 */941 942 #include <errno.h>943 #include <string.h>944 945 #if defined(_MSC_VER)946 #include <stdio.h>947 /* todo: fix this ugly rename hack */948 int myrename(char *from, char *to)949 {950 int r=1;951 char buf[1024];952 FILE *in, *out;953 in=fopen(from, "rb");954 if(in==0)955 return -1;956 out=fopen(to, "wb");957 if(out==0)958 return -1;959 while(!feof(in) && r>0)960 {961 r=fread(buf, 1, sizeof(buf), in);962 if(r>0)963 fwrite(buf, 1, r, out);964 }965 fclose(out);966 fclose(in);967 if(unlink(from) < 0)968 fprintf(stderr, "could not delete %s : %s\n", from, strerror(errno));969 970 return 0;971 }972 #else973 #define myrename rename974 #endif975 976 #include "def.h"977 #ifdef hpux978 #define sigvec sigvector979 #endif /* hpux */980 981 #ifdef X_POSIX_C_SOURCE982 #define _POSIX_C_SOURCE X_POSIX_C_SOURCE983 #include <signal.h>984 #undef _POSIX_C_SOURCE985 #else986 #if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)987 #include <signal.h>988 #else989 #define _POSIX_SOURCE990 #include <signal.h>991 #undef _POSIX_SOURCE992 #endif993 #endif994 995 #include <stdarg.h>996 997 #ifdef MINIX998 #define USE_CHMOD 1999 #endif1000 1001 #ifdef DEBUG1002 int _debugmask;1003 #endif1004 1005 /* #define DEBUG_DUMP */1006 #ifdef DEBUG_DUMP1007 #define DBG_PRINT(file, fmt, args) fprintf(file, fmt, args)1008 #else1009 #define DBG_PRINT(file, fmt, args) /* empty */1010 #endif1011 1012 #define DASH_INC_PRE "#include \""1013 #define DASH_INC_POST "\""1014 1015 char *ProgramName;1016 1017 char *directives[] = {1018 "if",1019 "ifdef",1020 "ifndef",1021 "else",1022 "endif",1023 "define",1024 "undef",1025 "include",1026 "line",1027 "pragma",1028 "error",1029 "ident",1030 "sccs",1031 "elif",1032 "eject",1033 "warning",1034 "include_next",1035 NULL1036 };1037 1038 #define MAKEDEPEND1039 #include "imakemdep.h" /* from config sources */1040 #undef MAKEDEPEND1041 1042 struct inclist inclist[ MAXFILES ],1043 *inclistp = inclist,1044 *inclistnext = inclist,1045 maininclist;1046 1047 static char *filelist[ MAXFILES ];1048 char *includedirs[ MAXDIRS + 1 ],1049 **includedirsnext = includedirs;1050 char *notdotdot[ MAXDIRS ];1051 static int cmdinc_count = 0;1052 static char *cmdinc_list[ 2 * MAXINCFILES ];1053 char *objprefix = "";1054 char *objsuffix = OBJSUFFIX;1055 static char *startat = "# DO NOT DELETE";1056 int width = 78;1057 static boolean append = FALSE;1058 boolean printed = FALSE;1059 boolean verbose = FALSE;1060 boolean show_where_not = FALSE;1061 /* Warn on multiple includes of same file */1062 boolean warn_multiple = FALSE;1063 1064 static void setfile_cmdinc(struct filepointer *filep, long count, char **list);1065 static void redirect(char *line, char *makefile);1066 1067 static1068 #ifdef SIGNALRETURNSINT1069 int1070 #else1071 void1072 #endif1073 catch (int sig)1074 {1075 fflush (stdout);1076 fatalerr ("got signal %d\n", sig);1077 }1078 1079 #if defined(USG) || (defined(i386) && defined(SYSV)) || defined(WIN32) || defined(__UNIXOS2__) || defined(Lynx_22) || defined(__CYGWIN__) || defined(_MSC_VER)1080 #define USGISH1081 #endif1082 1083 #ifndef USGISH1084 #ifdef X_NOT_POSIX1085 #define sigaction sigvec1086 #define sa_handler sv_handler1087 #define sa_mask sv_mask1088 #define sa_flags sv_flags1089 #endif1090 struct sigaction sig_act;1091 #endif /* USGISH */1092 1093 int1094 main(int argc, char *argv[])1095 {1096 char **fp = filelist;1097 char **incp = includedirs;1098 char *p;1099 struct inclist *ip;1100 char *makefile = NULL;1101 struct filepointer *filecontent;1102 struct symtab *psymp = predefs;1103 char *endmarker = NULL;1104 char *defincdir = NULL;1105 char **undeflist = NULL;1106 int numundefs = 0, i;1107 1108 ProgramName = argv[0];1109 1110 while (psymp->s_name)1111 {1112 define2(psymp->s_name, psymp->s_value, &maininclist);1113 psymp++;1114 }1115 if (argc == 2 && argv[1][0] == '@') {1116 struct stat ast;1117 int afd;1118 char *args;1119 char **nargv;1120 int nargc;1121 char quotechar = '\0';1122 1123 nargc = 1;1124 if ((afd = open(argv[1]+1, O_RDONLY)) < 0)1125 fatalerr("cannot open \"%s\"\n", argv[1]+1);1126 fstat(afd, &ast);1127 args = (char *)malloc(ast.st_size + 1);1128 if ((ast.st_size = read(afd, args, ast.st_size)) < 0)1129 fatalerr("failed to read %s\n", argv[1]+1);1130 args[ast.st_size] = '\0';1131 close(afd);1132 for (p = args; *p; p++) {1133 if (quotechar) {1134 if (quotechar == '\\' ||1135 (*p == quotechar && p[-1] != '\\'))1136 quotechar = '\0';1137 continue;1138 }1139 switch (*p) {1140 case '\\':1141 case '"':1142 case '\'':1143 quotechar = *p;1144 break;1145 case ' ':1146 case '\n':1147 *p = '\0';1148 if (p > args && p[-1])1149 nargc++;1150 break;1151 }1152 }1153 if (p[-1])1154 nargc++;1155 nargv = (char **)malloc(nargc * sizeof(char *));1156 nargv[0] = argv[0];1157 argc = 1;1158 for (p = args; argc < nargc; p += strlen(p) + 1)1159 if (*p) nargv[argc++] = p;1160 argv = nargv;1161 }1162 for(argc--, argv++; argc; argc--, argv++) {1163 /* if looking for endmarker then check before parsing */1164 if (endmarker && strcmp (endmarker, *argv) == 0) {1165 endmarker = NULL;1166 continue;1167 }1168 if (**argv != '-') {1169 /* treat +thing as an option for C++ */1170 if (endmarker && **argv == '+')1171 continue;1172 *fp++ = argv[0];1173 continue;1174 }1175 switch(argv[0][1]) {1176 case 'h':1177 case '?':1178 printf("see http://xfree86.org/current/makedepend.1.html\n");1179 return 0;1180 case '-':1181 endmarker = &argv[0][2];1182 if (endmarker[0] == '\0') endmarker = "--";1183 break;1184 case 'D':1185 if (argv[0][2] == '\0') {1186 argv++;1187 argc--;1188 }1189 for (p=argv[0] + 2; *p ; p++)1190 if (*p == '=') {1191 *p = ' ';1192 break;1193 }1194 define(argv[0] + 2, &maininclist);1195 break;1196 case 'I':1197 if (incp >= includedirs + MAXDIRS)1198 fatalerr("Too many -I flags.\n");1199 *incp++ = argv[0]+2;1200 if (**(incp-1) == '\0') {1201 *(incp-1) = *(++argv);1202 argc--;1203 }1204 break;1205 case 'U':1206 /* Undef's override all -D's so save them up */1207 numundefs++;1208 if (numundefs == 1)1209 undeflist = malloc(sizeof(char *));1210 else1211 undeflist = realloc(undeflist,1212 numundefs * sizeof(char *));1213 if (argv[0][2] == '\0') {1214 argv++;1215 argc--;1216 }1217 undeflist[numundefs - 1] = argv[0] + 2;1218 break;1219 case 'Y':1220 defincdir = argv[0]+2;1221 break;1222 /* do not use if endmarker processing */1223 case 'a':1224 if (endmarker) break;1225 append = TRUE;1226 break;1227 case 'w':1228 if (endmarker) break;1229 if (argv[0][2] == '\0') {1230 argv++;1231 argc--;1232 width = atoi(argv[0]);1233 } else1234 width = atoi(argv[0]+2);1235 break;1236 case 'o':1237 if (endmarker) break;1238 if (argv[0][2] == '\0') {1239 argv++;1240 argc--;1241 objsuffix = argv[0];1242 } else1243 objsuffix = argv[0]+2;1244 break;1245 case 'p':1246 if (endmarker) break;1247 if (argv[0][2] == '\0') {1248 argv++;1249 argc--;1250 objprefix = argv[0];1251 } else1252 objprefix = argv[0]+2;1253 break;1254 case 'v':1255 if (endmarker) break;1256 verbose = TRUE;1257 #ifdef DEBUG1258 if (argv[0][2])1259 _debugmask = atoi(argv[0]+2);1260 #endif1261 break;1262 case 's':1263 if (endmarker) break;1264 startat = argv[0]+2;1265 if (*startat == '\0') {1266 startat = *(++argv);1267 argc--;1268 }1269 if (*startat != '#')1270 fatalerr("-s flag's value should start %s\n",1271 "with '#'.");1272 break;1273 case 'f':1274 if (endmarker) break;1275 makefile = argv[0]+2;1276 if (*makefile == '\0') {1277 makefile = *(++argv);1278 argc--;1279 }1280 break;1281 1282 case 'm':1283 warn_multiple = TRUE;1284 break;1285 1286 /* Ignore -O, -g so we can just pass ${CFLAGS} to1287 makedepend1288 */1289 case 'O':1290 case 'g':1291 break;1292 case 'i':1293 if (strcmp(&argv[0][1],"include") == 0) {1294 char *buf;1295 if (argc<2)1296 fatalerr("option -include is a "1297 "missing its parameter\n");1298 if (cmdinc_count >= MAXINCFILES)1299 fatalerr("Too many -include flags.\n");1300 argc--;1301 argv++;1302 buf = malloc(strlen(DASH_INC_PRE) +1303 strlen(argv[0]) +1304 strlen(DASH_INC_POST) + 1);1305 if(!buf)1306 fatalerr("out of memory at "1307 "-include string\n");1308 cmdinc_list[2 * cmdinc_count + 0] = argv[0];1309 cmdinc_list[2 * cmdinc_count + 1] = buf;1310 cmdinc_count++;1311 break;1312 }1313 /* intentional fall through */1314 default:1315 if (endmarker) break;1316 /* fatalerr("unknown opt = %s\n", argv[0]); */1317 warning("ignoring option %s\n", argv[0]);1318 }1319 }1320 /* Now do the undefs from the command line */1321 for (i = 0; i < numundefs; i++)1322 undefine(undeflist[i], &maininclist);1323 if (numundefs > 0)1324 free(undeflist);1325 1326 if (!defincdir) {1327 #ifdef PREINCDIR1328 if (incp >= includedirs + MAXDIRS)1329 fatalerr("Too many -I flags.\n");1330 *incp++ = PREINCDIR;1331 #endif1332 #if defined(__UNIXOS2__) || defined(STANDALONE)1333 {1334 char *emxinc = getenv("C_INCLUDE_PATH");1335 /* can have more than one component */1336 if (emxinc) {1337 char *beg, *end;1338 beg= (char*)strdup(emxinc);1339 for (;;) {1340 end = (char*)strchr(beg,';');1341 if (end) *end = 0;1342 if (incp >= includedirs + MAXDIRS)1343 fatalerr("Too many include dirs\n");1344 *incp++ = beg;1345 if (!end) break;1346 beg = end+1;1347 }1348 }1349 }1350 #else /* !__UNIXOS2__, does not use INCLUDEDIR at all */1351 if (incp >= includedirs + MAXDIRS)1352 fatalerr("Too many -I flags.\n");1353 *incp++ = INCLUDEDIR;1354 #endif1355 1356 #if defined(_MSC_VER)1357 /* MSVC defines the INCLUDE environment variable */1358 {1359 char *emxinc = getenv("INCLUDE");1360 /* can have more than one component */1361 if (emxinc) {1362 char *beg, *end;1363 beg= (char*)strdup(emxinc);1364 for (;;) {1365 end = (char*)strchr(beg,';');1366 if (end) *end = 0;1367 if (incp >= includedirs + MAXDIRS)1368 fatalerr("Too many include dirs\n");1369 *incp++ = beg;1370 if (!end) break;1371 beg = end+1;1372 }1373 }1374 }1375 #endif1376 1377 #ifdef EXTRAINCDIR1378 if (incp >= includedirs + MAXDIRS)1379 fatalerr("Too many -I flags.\n");1380 *incp++ = EXTRAINCDIR;1381 #endif1382 1383 #ifdef POSTINCDIR1384 if (incp >= includedirs + MAXDIRS)1385 fatalerr("Too many -I flags.\n");1386 *incp++ = POSTINCDIR;1387 #endif1388 } else if (*defincdir) {1389 if (incp >= includedirs + MAXDIRS)1390 fatalerr("Too many -I flags.\n");1391 *incp++ = defincdir;1392 }1393 1394 redirect(startat, makefile);1395 1396 /*1397 * catch signals.1398 */1399 #ifdef USGISH1400 /* should really reset SIGINT to SIG_IGN if it was. */1401 #ifdef SIGHUP1402 signal (SIGHUP, catch);1403 #endif1404 signal (SIGINT, catch);1405 #ifdef SIGQUIT1406 signal (SIGQUIT, catch);1407 #endif1408 signal (SIGILL, catch);1409 #ifdef SIGBUS1410 signal (SIGBUS, catch);1411 #endif1412 signal (SIGSEGV, catch);1413 #ifdef SIGSYS1414 signal (SIGSYS, catch);1415 #endif1416 #else1417 sig_act.sa_handler = catch;1418 #if defined(_POSIX_SOURCE) || !defined(X_NOT_POSIX)1419 sigemptyset(&sig_act.sa_mask);1420 sigaddset(&sig_act.sa_mask, SIGINT);1421 sigaddset(&sig_act.sa_mask, SIGQUIT);1422 #ifdef SIGBUS1423 sigaddset(&sig_act.sa_mask, SIGBUS);1424 #endif1425 sigaddset(&sig_act.sa_mask, SIGILL);1426 sigaddset(&sig_act.sa_mask, SIGSEGV);1427 sigaddset(&sig_act.sa_mask, SIGHUP);1428 sigaddset(&sig_act.sa_mask, SIGPIPE);1429 #ifdef SIGSYS1430 sigaddset(&sig_act.sa_mask, SIGSYS);1431 #endif1432 #else1433 sig_act.sa_mask = ((1<<(SIGINT -1))1434 |(1<<(SIGQUIT-1))1435 #ifdef SIGBUS1436 |(1<<(SIGBUS-1))1437 #endif1438 |(1<<(SIGILL-1))1439 |(1<<(SIGSEGV-1))1440 |(1<<(SIGHUP-1))1441 |(1<<(SIGPIPE-1))1442 #ifdef SIGSYS1443 |(1<<(SIGSYS-1))1444 #endif1445 );1446 #endif /* _POSIX_SOURCE */1447 sig_act.sa_flags = 0;1448 sigaction(SIGHUP, &sig_act, (struct sigaction *)0);1449 sigaction(SIGINT, &sig_act, (struct sigaction *)0);1450 sigaction(SIGQUIT, &sig_act, (struct sigaction *)0);1451 sigaction(SIGILL, &sig_act, (struct sigaction *)0);1452 #ifdef SIGBUS1453 sigaction(SIGBUS, &sig_act, (struct sigaction *)0);1454 #endif1455 sigaction(SIGSEGV, &sig_act, (struct sigaction *)0);1456 #ifdef SIGSYS1457 sigaction(SIGSYS, &sig_act, (struct sigaction *)0);1458 #endif1459 #endif /* USGISH */1460 1461 /*1462 * now peruse through the list of files.1463 */1464 for(fp=filelist; *fp; fp++) {1465 DBG_PRINT(stderr,"file: %s\n",*fp);1466 filecontent = getfile(*fp);1467 setfile_cmdinc(filecontent, cmdinc_count, cmdinc_list);1468 ip = newinclude(*fp, (char *)NULL);1469 1470 find_includes(filecontent, ip, ip, 0, FALSE);1471 freefile(filecontent);1472 recursive_pr_include(ip, ip->i_file, base_name(*fp));1473 inc_clean();1474 }1475 if (printed)1476 printf("\n");1477 return 0;1478 }1479 1480 #ifdef __UNIXOS2__1481 /*1482 * eliminate \r chars from file1483 */1484 static int1485 elim_cr(char *buf, int sz)1486 {1487 int i,wp;1488 for (i= wp = 0; i<sz; i++) {1489 if (buf[i] != '\r')1490 buf[wp++] = buf[i];1491 }1492 return wp;1493 }1494 #endif1495 1496 struct filepointer *1497 getfile(char *file)1498 {1499 int fd;1500 struct filepointer *content;1501 struct stat st;1502 1503 content = (struct filepointer *)malloc(sizeof(struct filepointer));1504 content->f_name = file;1505 if ((fd = open(file, O_RDONLY)) < 0) {1506 warning("cannot open \"%s\"\n", file);1507 content->f_p = content->f_base = content->f_end = (char *)malloc(1);1508 *content->f_p = '\0';1509 return(content);1510 }1511 fstat(fd, &st);1512 content->f_base = (char *)malloc(st.st_size+1);1513 if (content->f_base == NULL)1514 fatalerr("cannot allocate mem\n");1515 if ((st.st_size = read(fd, content->f_base, st.st_size)) < 0)1516 fatalerr("failed to read %s\n", file);1517 #ifdef __UNIXOS2__1518 st.st_size = elim_cr(content->f_base,st.st_size);1519 #endif1520 close(fd);1521 content->f_len = st.st_size+1;1522 content->f_p = content->f_base;1523 content->f_end = content->f_base + st.st_size;1524 *content->f_end = '\0';1525 content->f_line = 0;1526 content->cmdinc_count = 0;1527 content->cmdinc_list = NULL;1528 content->cmdinc_line = 0;1529 return(content);1530 }1531 1532 void1533 setfile_cmdinc(struct filepointer* filep, long count, char** list)1534 {1535 filep->cmdinc_count = count;1536 filep->cmdinc_list = list;1537 filep->cmdinc_line = 0;1538 }1539 1540 void1541 freefile(struct filepointer *fp)1542 {1543 free(fp->f_base);1544 free(fp);1545 }1546 1547 char *copy(char *str)1548 {1549 char *p = (char *)malloc(strlen(str) + 1);1550 1551 strcpy(p, str);1552 return(p);1553 }1554 1555 int1556 match(char *str, char **list)1557 {1558 int i;1559 1560 for (i=0; *list; i++, list++)1561 if (strcmp(str, *list) == 0)1562 return(i);1563 return(-1);1564 }1565 1566 /*1567 * Get the next line. We only return lines beginning with '#' since that1568 * is all this program is ever interested in.1569 */1570 char *getnextline(struct filepointer *filep)1571 {1572 char *p, /* walking pointer */1573 *eof, /* end of file pointer */1574 *bol; /* beginning of line pointer */1575 int lineno; /* line number */1576 boolean whitespace = FALSE;1577 1578 /*1579 * Fake the "-include" line files in form of #include to the1580 * start of each file.1581 */1582 if (filep->cmdinc_line < filep->cmdinc_count) {1583 char *inc = filep->cmdinc_list[2 * filep->cmdinc_line + 0];1584 char *buf = filep->cmdinc_list[2 * filep->cmdinc_line + 1];1585 filep->cmdinc_line++;1586 sprintf(buf,"%s%s%s",DASH_INC_PRE,inc,DASH_INC_POST);1587 DBG_PRINT(stderr,"%s\n",buf);1588 return(buf);1589 }1590 1591 p = filep->f_p;1592 eof = filep->f_end;1593 if (p >= eof)1594 return((char *)NULL);1595 lineno = filep->f_line;1596 1597 for (bol = p--; ++p < eof; ) {1598 if ((bol == p) && ((*p == ' ') || (*p == '\t')))1599 {1600 /* Consume leading white-spaces for this line */1601 while (((p+1) < eof) && ((*p == ' ') || (*p == '\t')))1602 {1603 p++;1604 bol++;1605 }1606 whitespace = TRUE;1607 }1608 1609 if (*p == '/' && (p+1) < eof && *(p+1) == '*') {1610 /* Consume C comments */1611 *(p++) = ' ';1612 *(p++) = ' ';1613 while (p < eof && *p) {1614 if (*p == '*' && (p+1) < eof && *(p+1) == '/') {1615 *(p++) = ' ';1616 *(p++) = ' ';1617 break;1618 }1619 if (*p == '\n')1620 lineno++;1621 *(p++) = ' ';1622 }1623 --p;1624 }1625 else if (*p == '/' && (p+1) < eof && *(p+1) == '/') {1626 /* Consume C++ comments */1627 *(p++) = ' ';1628 *(p++) = ' ';1629 while (p < eof && *p) {1630 if (*p == '\\' && (p+1) < eof &&1631 *(p+1) == '\n') {1632 *(p++) = ' ';1633 lineno++;1634 }1635 else if (*p == '?' && (p+3) < eof &&1636 *(p+1) == '?' &&1637 *(p+2) == '/' &&1638 *(p+3) == '\n') {1639 *(p++) = ' ';1640 *(p++) = ' ';1641 *(p++) = ' ';1642 lineno++;1643 }1644 else if (*p == '\n')1645 break; /* to process end of line */1646 *(p++) = ' ';1647 }1648 --p;1649 }1650 else if (*p == '\\' && (p+1) < eof && *(p+1) == '\n') {1651 /* Consume backslash line terminations */1652 *(p++) = ' ';1653 *p = ' ';1654 lineno++;1655 }1656 else if (*p == '?' && (p+3) < eof &&1657 *(p+1) == '?' && *(p+2) == '/' && *(p+3) == '\n') {1658 /* Consume trigraph'ed backslash line terminations */1659 *(p++) = ' ';1660 *(p++) = ' ';1661 *(p++) = ' ';1662 *p = ' ';1663 lineno++;1664 }1665 else if (*p == '\n') {1666 lineno++;1667 if (*bol == '#') {1668 char *cp;1669 1670 *(p++) = '\0';1671 /* punt lines with just # (yacc generated) */1672 for (cp = bol+1;1673 *cp && (*cp == ' ' || *cp == '\t'); cp++);1674 if (*cp) goto done;1675 --p;1676 }1677 bol = p+1;1678 whitespace = FALSE;1679 }1680 }1681 if (*bol != '#')1682 bol = NULL;1683 done:1684 if (bol && whitespace) {1685 // warning("%s: non-portable whitespace encountered at line %d\n",1686 // filep->f_name, lineno);1687 }1688 filep->f_p = p;1689 filep->f_line = lineno;1690 #ifdef DEBUG_DUMP1691 if (bol)1692 DBG_PRINT(stderr,"%s\n",bol);1693 #endif1694 return(bol);1695 }1696 1697 /*1698 * Strip the file name down to what we want to see in the Makefile.1699 * It will have objprefix and objsuffix around it.1700 */1701 char *base_name(char *file)1702 {1703 char *p;1704 1705 file = copy(file);1706 for(p=file+strlen(file); p>file && *p != '.'; p--) ;1707 1708 if (*p == '.')1709 *p = '\0';1710 return(file);1711 }1712 1713 #if defined(USG) && !defined(CRAY) && !defined(SVR4) && !defined(__UNIXOS2__) && !defined(clipper) && !defined(__clipper__)1714 int myrename (char *from, char *to)1715 {1716 (void) unlink (to);1717 if (link (from, to) == 0) {1718 unlink (from);1719 return 0;1720 } else {1721 return -1;1722 }1723 }1724 #endif /* USGISH */1725 1726 void1727 redirect(char *line, char *makefile)1728 {1729 struct stat st;1730 FILE *fdin, *fdout;1731 char backup[ BUFSIZ ],1732 buf[ BUFSIZ ];1733 boolean found = FALSE;1734 int len;1735 1736 /*1737 * if makefile is "-" then let it pour onto stdout.1738 */1739 if (makefile && *makefile == '-' && *(makefile+1) == '\0') {1740 puts(line);1741 return;1742 }1743 1744 /*1745 * use a default makefile is not specified.1746 */1747 if (!makefile) {1748 if (stat("Makefile", &st) == 0)1749 makefile = "Makefile";1750 else if (stat("makefile", &st) == 0)1751 makefile = "makefile";1752 else1753 fatalerr("[mM]akefile is not present\n");1754 }1755 else1756 stat(makefile, &st);1757 if ((fdin = fopen(makefile, "r")) == NULL)1758 fatalerr("cannot open \"%s\"\n", makefile);1759 sprintf(backup, "%s.bak", makefile);1760 unlink(backup);1761 #if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)1762 fclose(fdin);1763 #endif1764 if (myrename(makefile, backup) < 0)1765 fatalerr("cannot rename %s to %s : %s\n", makefile, backup, strerror(errno));1766 #if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)1767 if ((fdin = fopen(backup, "r")) == NULL)1768 fatalerr("cannot open \"%s\"\n", backup);1769 #endif1770 if ((fdout = freopen(makefile, "w", stdout)) == NULL)1771 fatalerr("cannot open \"%s\"\n", backup);1772 len = strlen(line);1773 while (!found && fgets(buf, BUFSIZ, fdin)) {1774 if (*buf == '#' && strncmp(line, buf, len) == 0)1775 found = TRUE;1776 fputs(buf, fdout);1777 }1778 if (!found) {1779 if (verbose)1780 warning("Adding new delimiting line \"%s\" and dependencies...\n",1781 line);1782 puts(line); /* same as fputs(fdout); but with newline */1783 } else if (append) {1784 while (fgets(buf, BUFSIZ, fdin)) {1785 fputs(buf, fdout);1786 }1787 }1788 fflush(fdout);1789 #if defined(USGISH) || defined(_SEQUENT_) || defined(USE_CHMOD)1790 chmod(makefile, st.st_mode);1791 #else1792 fchmod(fileno(fdout), st.st_mode);1793 #endif /* USGISH */1794 }1795 1796 void1797 fatalerr(char *msg, ...)1798 {1799 va_list args;1800 fprintf(stderr, "%s: error: ", ProgramName);1801 va_start(args, msg);1802 vfprintf(stderr, msg, args);1803 va_end(args);1804 exit (1);1805 }1806 1807 void1808 warning(char *msg, ...)1809 {1810 va_list args;1811 fprintf(stderr, "%s: warning: ", ProgramName);1812 va_start(args, msg);1813 vfprintf(stderr, msg, args);1814 va_end(args);1815 }1816 1817 void1818 warning1(char *msg, ...)1819 {1820 va_list args;1821 va_start(args, msg);1822 vfprintf(stderr, msg, args);1823 va_end(args);1824 } -
parse.c
683 683 debug(2,("finished with %s\n", file->i_file)); 684 684 return(-1); 685 685 } 686 /*687 688 Copyright (c) 1993, 1994, 1998 The Open Group689 690 Permission to use, copy, modify, distribute, and sell this software and its691 documentation for any purpose is hereby granted without fee, provided that692 the above copyright notice appear in all copies and that both that693 copyright notice and this permission notice appear in supporting694 documentation.695 696 The above copyright notice and this permission notice shall be included in697 all copies or substantial portions of the Software.698 699 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR700 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,701 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE702 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN703 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN704 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.705 706 Except as contained in this notice, the name of The Open Group shall not be707 used in advertising or otherwise to promote the sale, use or other dealings708 in this Software without prior written authorization from The Open Group.709 710 */711 /* $Header: /code/makedepend/parse.c,v 1.3 2005/03/03 18:13:08 doj Exp $ */712 713 #include "def.h"714 715 extern char *directives[];716 extern struct inclist inclist[ MAXFILES ],717 *inclistnext,718 maininclist;719 extern char *includedirs[ ],720 **includedirsnext;721 722 static int deftype (char *line, struct filepointer *filep,723 struct inclist *file_red, struct inclist *file,724 int parse_it);725 static int zero_value(char *filename, char *exp, struct filepointer *filep,726 struct inclist *file_red);727 static int merge2defines(struct inclist *file1, struct inclist *file2);728 729 static int730 gobble(struct filepointer *filep, struct inclist *file,731 struct inclist *file_red)732 {733 char *line;734 int type;735 736 while ((line = getnextline(filep))) {737 switch(type = deftype(line, filep, file_red, file, FALSE)) {738 case IF:739 case IFFALSE:740 case IFGUESSFALSE:741 case IFDEF:742 case IFNDEF:743 type = gobble(filep, file, file_red);744 while ((type == ELIF) || (type == ELIFFALSE) ||745 (type == ELIFGUESSFALSE))746 type = gobble(filep, file, file_red);747 if (type == ELSE)748 (void)gobble(filep, file, file_red);749 break;750 case ELSE:751 case ENDIF:752 debug(0,("%s, line %d: #%s\n",753 file->i_file, filep->f_line,754 directives[type]));755 return(type);756 case DEFINE:757 case UNDEF:758 case INCLUDE:759 case INCLUDEDOT:760 case PRAGMA:761 case ERROR:762 case IDENT:763 case SCCS:764 case EJECT:765 case WARNING:766 case INCLUDENEXT:767 case INCLUDENEXTDOT:768 break;769 case ELIF:770 case ELIFFALSE:771 case ELIFGUESSFALSE:772 return(type);773 case -1:774 warning("%s", file_red->i_file);775 if (file_red != file)776 warning1(" (reading %s)", file->i_file);777 warning1(", line %d: unknown directive == \"%s\"\n",778 filep->f_line, line);779 break;780 }781 }782 return(-1);783 }784 785 /*786 * Decide what type of # directive this line is.787 */788 static int789 deftype (char *line, struct filepointer *filep,790 struct inclist *file_red, struct inclist *file, int parse_it)791 {792 register char *p;793 char *directive, savechar, *q;794 register int ret;795 796 /*797 * Parse the directive...798 */799 directive=line+1;800 while (*directive == ' ' || *directive == '\t')801 directive++;802 803 p = directive;804 while ((*p == '_') || (*p >= 'a' && *p <= 'z'))805 p++;806 savechar = *p;807 *p = '\0';808 ret = match(directive, directives);809 *p = savechar;810 811 /* If we don't recognize this compiler directive or we happen to just812 * be gobbling up text while waiting for an #endif or #elif or #else813 * in the case of an #elif we must check the zero_value and return an814 * ELIF or an ELIFFALSE.815 */816 817 if (ret == ELIF && !parse_it)818 {819 while (*p == ' ' || *p == '\t')820 p++;821 /*822 * parse an expression.823 */824 debug(0,("%s, line %d: #elif %s ",825 file->i_file, filep->f_line, p));826 ret = zero_value(file->i_file, p, filep, file_red);827 if (ret != IF)828 {829 debug(0,("false...\n"));830 if (ret == IFFALSE)831 return(ELIFFALSE);832 else833 return(ELIFGUESSFALSE);834 }835 else836 {837 debug(0,("true...\n"));838 return(ELIF);839 }840 }841 842 if (ret < 0 || ! parse_it)843 return(ret);844 845 /*846 * now decide how to parse the directive, and do it.847 */848 while (*p == ' ' || *p == '\t')849 p++;850 q = p + strlen(p);851 do {852 q--;853 } while (*q == ' ' || *q == '\t');854 q[1] = '\0';855 switch (ret) {856 case IF:857 /*858 * parse an expression.859 */860 ret = zero_value(file->i_file, p, filep, file_red);861 debug(0,("%s, line %d: %s #if %s\n",862 file->i_file, filep->f_line, ret?"false":"true", p));863 break;864 case IFDEF:865 case IFNDEF:866 debug(0,("%s, line %d: #%s %s\n",867 file->i_file, filep->f_line, directives[ret], p));868 case UNDEF:869 /*870 * separate the name of a single symbol.871 */872 while (isalnum(*p) || *p == '_')873 *line++ = *p++;874 *line = '\0';875 break;876 case INCLUDE:877 case INCLUDENEXT:878 debug(2,("%s, line %d: #include%s %s\n",879 file->i_file, filep->f_line,880 (ret == INCLUDE) ? "" : "_next", p));881 882 /* Support ANSI macro substitution */883 while (1) {884 struct symtab **sym;885 886 if (!*p || *p == '"' || *p == '<')887 break;888 889 sym = isdefined(p, file_red, NULL);890 if (!sym)891 break;892 893 p = (*sym)->s_value;894 debug(3,("%s : #includes SYMBOL %s = %s\n",895 file->i_incstring,896 (*sym) -> s_name,897 (*sym) -> s_value));898 /* mark file as having included a 'soft include' */899 file->i_flags |= INCLUDED_SYM;900 }901 902 /*903 * Separate the name of the include file.904 */905 while (*p && *p != '"' && *p != '<')906 p++;907 if (! *p)908 return(-2);909 if (*p++ == '"') {910 if (ret == INCLUDE)911 ret = INCLUDEDOT;912 else913 ret = INCLUDENEXTDOT;914 while (*p && *p != '"')915 *line++ = *p++;916 } else917 while (*p && *p != '>')918 *line++ = *p++;919 *line = '\0';920 break;921 case DEFINE:922 /*923 * copy the definition back to the beginning of the line.924 */925 strcpy (line, p);926 break;927 case ELSE:928 case ENDIF:929 case ELIF:930 case PRAGMA:931 case ERROR:932 case IDENT:933 case SCCS:934 case EJECT:935 case WARNING:936 debug(0,("%s, line %d: #%s\n",937 file->i_file, filep->f_line, directives[ret]));938 /*939 * nothing to do.940 */941 break;942 }943 return(ret);944 }945 946 struct symtab **947 fdefined(char *symbol, struct inclist *file, struct inclist **srcfile)948 {949 struct inclist **ip;950 struct symtab **val;951 int i;952 static int recurse_lvl = 0;953 954 if (file->i_flags & DEFCHECKED)955 return(NULL);956 debug(2,("Looking for %s in %s\n", symbol, file->i_file));957 file->i_flags |= DEFCHECKED;958 if ((val = slookup(symbol, file)))959 debug(1,("%s defined in %s as %s\n",960 symbol, file->i_file, (*val)->s_value));961 if (val == NULL && file->i_list)962 {963 for (ip = file->i_list, i=0; i < file->i_listlen; i++, ip++)964 if (file->i_merged[i]==FALSE) {965 val = fdefined(symbol, *ip, srcfile);966 file->i_merged[i]=merge2defines(file,*ip);967 if (val!=NULL) break;968 }969 }970 else if (val != NULL && srcfile != NULL) *srcfile = file;971 recurse_lvl--;972 file->i_flags &= ~DEFCHECKED;973 974 return(val);975 }976 977 struct symtab **978 isdefined(char *symbol, struct inclist *file, struct inclist **srcfile)979 {980 struct symtab **val;981 982 if ((val = slookup(symbol, &maininclist))) {983 debug(1,("%s defined on command line\n", symbol));984 if (srcfile != NULL) *srcfile = &maininclist;985 return(val);986 }987 if ((val = fdefined(symbol, file, srcfile)))988 return(val);989 debug(1,("%s not defined in %s\n", symbol, file->i_file));990 return(NULL);991 }992 993 /*994 * Return type based on if the #if expression evaluates to 0995 */996 static int997 zero_value(char *filename,998 char *exp,999 struct filepointer *filep,1000 struct inclist *file_red)1001 {1002 if (cppsetup(filename, exp, filep, file_red))1003 return(IFFALSE);1004 else1005 return(IF);1006 }1007 1008 void1009 define2(char *name, char *val, struct inclist *file)1010 {1011 int first, last, below;1012 register struct symtab **sp = NULL, **dest;1013 struct symtab *stab;1014 1015 /* Make space if it's needed */1016 if (file->i_defs == NULL)1017 {1018 file->i_defs = (struct symtab **)1019 malloc(sizeof (struct symtab*) * SYMTABINC);1020 file->i_ndefs = 0;1021 }1022 else if (!(file->i_ndefs % SYMTABINC))1023 file->i_defs = (struct symtab **)1024 realloc(file->i_defs,1025 sizeof(struct symtab*)*(file->i_ndefs+SYMTABINC));1026 1027 if (file->i_defs == NULL)1028 fatalerr("malloc()/realloc() failure in insert_defn()\n");1029 1030 below = first = 0;1031 last = file->i_ndefs - 1;1032 while (last >= first)1033 {1034 /* Fast inline binary search */1035 register char *s1;1036 register char *s2;1037 register int middle = (first + last) / 2;1038 1039 /* Fast inline strchr() */1040 s1 = name;1041 s2 = file->i_defs[middle]->s_name;1042 while (*s1++ == *s2++)1043 if (s2[-1] == '\0') break;1044 1045 /* If exact match, set sp and break */1046 if (*--s1 == *--s2)1047 {1048 sp = file->i_defs + middle;1049 break;1050 }1051 1052 /* If name > i_defs[middle] ... */1053 if (*s1 > *s2)1054 {1055 below = first;1056 first = middle + 1;1057 }1058 /* else ... */1059 else1060 {1061 below = last = middle - 1;1062 }1063 }1064 1065 /* Search is done. If we found an exact match to the symbol name,1066 just replace its s_value */1067 if (sp != NULL)1068 {1069 debug(1,("redefining %s from %s to %s in file %s\n",1070 name, (*sp)->s_value, val, file->i_file));1071 free((*sp)->s_value);1072 (*sp)->s_value = copy(val);1073 return;1074 }1075 1076 sp = file->i_defs + file->i_ndefs++;1077 dest = file->i_defs + below + 1;1078 while (sp > dest)1079 {1080 *sp = sp[-1];1081 sp--;1082 }1083 stab = (struct symtab *) malloc(sizeof (struct symtab));1084 if (stab == NULL)1085 fatalerr("malloc()/realloc() failure in insert_defn()\n");1086 1087 debug(1,("defining %s to %s in file %s\n", name, val, file->i_file));1088 stab->s_name = copy(name);1089 stab->s_value = copy(val);1090 *sp = stab;1091 }1092 1093 void1094 define(char *def, struct inclist *file)1095 {1096 char *val;1097 1098 /* Separate symbol name and its value */1099 val = def;1100 while (isalnum(*val) || *val == '_')1101 val++;1102 if (*val)1103 *val++ = '\0';1104 while (*val == ' ' || *val == '\t')1105 val++;1106 1107 if (!*val)1108 val = "1";1109 define2(def, val, file);1110 }1111 1112 struct symtab **1113 slookup(char *symbol, struct inclist *file)1114 {1115 register int first = 0;1116 register int last = file->i_ndefs - 1;1117 1118 if (file) while (last >= first)1119 {1120 /* Fast inline binary search */1121 register char *s1;1122 register char *s2;1123 register int middle = (first + last) / 2;1124 1125 /* Fast inline strchr() */1126 s1 = symbol;1127 s2 = file->i_defs[middle]->s_name;1128 while (*s1++ == *s2++)1129 if (s2[-1] == '\0') break;1130 1131 /* If exact match, we're done */1132 if (*--s1 == *--s2)1133 {1134 return file->i_defs + middle;1135 }1136 1137 /* If symbol > i_defs[middle] ... */1138 if (*s1 > *s2)1139 {1140 first = middle + 1;1141 }1142 /* else ... */1143 else1144 {1145 last = middle - 1;1146 }1147 }1148 return(NULL);1149 }1150 1151 static int1152 merge2defines(struct inclist *file1, struct inclist *file2)1153 {1154 int i;1155 1156 if ((file1==NULL) || (file2==NULL) ||1157 !(file2->i_flags & FINISHED))1158 return 0;1159 1160 for (i=0; i < file2->i_listlen; i++)1161 if (file2->i_merged[i]==FALSE)1162 return 0;1163 1164 {1165 int first1 = 0;1166 int last1 = file1->i_ndefs - 1;1167 1168 int first2 = 0;1169 int last2 = file2->i_ndefs - 1;1170 1171 int first=0;1172 struct symtab** i_defs = NULL;1173 int deflen=file1->i_ndefs+file2->i_ndefs;1174 1175 debug(2,("merging %s into %s\n",1176 file2->i_file, file1->i_file));1177 1178 if (deflen>0)1179 {1180 /* make sure deflen % SYMTABINC == 0 is still true */1181 deflen += (SYMTABINC - deflen % SYMTABINC) % SYMTABINC;1182 i_defs=(struct symtab**)1183 malloc(deflen*sizeof(struct symtab*));1184 if (i_defs==NULL) return 0;1185 }1186 1187 while ((last1 >= first1) && (last2 >= first2))1188 {1189 char *s1=file1->i_defs[first1]->s_name;1190 char *s2=file2->i_defs[first2]->s_name;1191 1192 if (strcmp(s1,s2) < 0)1193 i_defs[first++]=file1->i_defs[first1++];1194 else if (strcmp(s1,s2) > 0)1195 i_defs[first++]=file2->i_defs[first2++];1196 else /* equal */1197 {1198 i_defs[first++]=file2->i_defs[first2++];1199 first1++;1200 }1201 }1202 while (last1 >= first1)1203 {1204 i_defs[first++]=file1->i_defs[first1++];1205 }1206 while (last2 >= first2)1207 {1208 i_defs[first++]=file2->i_defs[first2++];1209 }1210 1211 if (file1->i_defs) free(file1->i_defs);1212 file1->i_defs=i_defs;1213 file1->i_ndefs=first;1214 1215 return 1;1216 }1217 }1218 1219 void1220 undefine(char *symbol, struct inclist *file)1221 {1222 register struct symtab **ptr;1223 struct inclist *srcfile;1224 while ((ptr = isdefined(symbol, file, &srcfile)) != NULL)1225 {1226 srcfile->i_ndefs--;1227 for (; ptr < srcfile->i_defs + srcfile->i_ndefs; ptr++)1228 *ptr = ptr[1];1229 }1230 }1231 1232 int1233 find_includes(struct filepointer *filep, struct inclist *file,1234 struct inclist *file_red, int recursion, boolean failOK)1235 {1236 struct inclist *inclistp;1237 char **includedirsp;1238 register char *line;1239 register int type;1240 boolean recfailOK;1241 1242 while ((line = getnextline(filep))) {1243 switch(type = deftype(line, filep, file_red, file, TRUE)) {1244 case IF:1245 doif:1246 type = find_includes(filep, file,1247 file_red, recursion+1, failOK);1248 while ((type == ELIF) || (type == ELIFFALSE) ||1249 (type == ELIFGUESSFALSE))1250 type = gobble(filep, file, file_red);1251 if (type == ELSE)1252 gobble(filep, file, file_red);1253 break;1254 case IFFALSE:1255 case IFGUESSFALSE:1256 doiffalse:1257 if (type == IFGUESSFALSE || type == ELIFGUESSFALSE)1258 recfailOK = TRUE;1259 else1260 recfailOK = failOK;1261 type = gobble(filep, file, file_red);1262 if (type == ELSE)1263 find_includes(filep, file,1264 file_red, recursion+1, recfailOK);1265 else1266 if (type == ELIF)1267 goto doif;1268 else1269 if ((type == ELIFFALSE) || (type == ELIFGUESSFALSE))1270 goto doiffalse;1271 break;1272 case IFDEF:1273 case IFNDEF:1274 if ((type == IFDEF && isdefined(line, file_red, NULL))1275 || (type == IFNDEF && !isdefined(line, file_red, NULL))) {1276 debug(1,(type == IFNDEF ?1277 "line %d: %s !def'd in %s via %s%s\n" : "",1278 filep->f_line, line,1279 file->i_file, file_red->i_file, ": doit"));1280 type = find_includes(filep, file,1281 file_red, recursion+1, failOK);1282 while (type == ELIF || type == ELIFFALSE || type == ELIFGUESSFALSE)1283 type = gobble(filep, file, file_red);1284 if (type == ELSE)1285 gobble(filep, file, file_red);1286 }1287 else {1288 debug(1,(type == IFDEF ?1289 "line %d: %s !def'd in %s via %s%s\n" : "",1290 filep->f_line, line,1291 file->i_file, file_red->i_file, ": gobble"));1292 type = gobble(filep, file, file_red);1293 if (type == ELSE)1294 find_includes(filep, file,1295 file_red, recursion+1, failOK);1296 else if (type == ELIF)1297 goto doif;1298 else if (type == ELIFFALSE || type == ELIFGUESSFALSE)1299 goto doiffalse;1300 }1301 break;1302 case ELSE:1303 case ELIFFALSE:1304 case ELIFGUESSFALSE:1305 case ELIF:1306 if (!recursion)1307 gobble(filep, file, file_red);1308 case ENDIF:1309 if (recursion)1310 return(type);1311 case DEFINE:1312 define(line, file);1313 break;1314 case UNDEF:1315 if (!*line) {1316 warning("%s", file_red->i_file);1317 if (file_red != file)1318 warning1(" (reading %s)", file->i_file);1319 warning1(", line %d: incomplete undef == \"%s\"\n",1320 filep->f_line, line);1321 break;1322 }1323 undefine(line, file_red);1324 break;1325 case INCLUDE:1326 case INCLUDEDOT:1327 case INCLUDENEXT:1328 case INCLUDENEXTDOT:1329 inclistp = inclistnext;1330 includedirsp = includedirsnext;1331 debug(2,("%s, reading %s, includes %s\n",1332 file_red->i_file, file->i_file, line));1333 add_include(filep, file, file_red, line, type, failOK);1334 inclistnext = inclistp;1335 includedirsnext = includedirsp;1336 break;1337 case ERROR:1338 case WARNING:1339 warning("%s", file_red->i_file);1340 if (file_red != file)1341 warning1(" (reading %s)", file->i_file);1342 warning1(", line %d: %s\n",1343 filep->f_line, line);1344 break;1345 1346 case PRAGMA:1347 case IDENT:1348 case SCCS:1349 case EJECT:1350 break;1351 case -1:1352 warning("%s", file_red->i_file);1353 if (file_red != file)1354 warning1(" (reading %s)", file->i_file);1355 warning1(", line %d: unknown directive == \"%s\"\n",1356 filep->f_line, line);1357 break;1358 case -2:1359 warning("%s", file_red->i_file);1360 if (file_red != file)1361 warning1(" (reading %s)", file->i_file);1362 warning1(", line %d: incomplete include == \"%s\"\n",1363 filep->f_line, line);1364 break;1365 }1366 }1367 file->i_flags |= FINISHED;1368 debug(2,("finished with %s\n", file->i_file));1369 return(-1);1370 } -
ifparser.c
546 546 { 547 547 return parse_cond (g, cp, valp); 548 548 } 549 /*550 * Copyright 1992 Network Computing Devices, Inc.551 *552 * Permission to use, copy, modify, and distribute this software and its553 * documentation for any purpose and without fee is hereby granted, provided554 * that the above copyright notice appear in all copies and that both that555 * copyright notice and this permission notice appear in supporting556 * documentation, and that the name of Network Computing Devices may not be557 * used in advertising or publicity pertaining to distribution of the software558 * without specific, written prior permission. Network Computing Devices makes559 * no representations about the suitability of this software for any purpose.560 * It is provided ``as is'' without express or implied warranty.561 *562 * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS563 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,564 * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL,565 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM566 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE567 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR568 * PERFORMANCE OF THIS SOFTWARE.569 *570 * Author: Jim Fulton571 * Network Computing Devices, Inc.572 *573 * Simple if statement processor574 *575 * This module can be used to evaluate string representations of C language576 * if constructs. It accepts the following grammar:577 *578 * EXPRESSION := VALUE579 * | VALUE BINOP EXPRESSION580 * | VALUE '?' EXPRESSION ':' EXPRESSION581 *582 * VALUE := '(' EXPRESSION ')'583 * | '!' VALUE584 * | '-' VALUE585 * | '+' VALUE586 * | '~' VALUE587 * | 'defined' '(' variable ')'588 * | 'defined' variable589 * | # variable '(' variable-list ')'590 * | variable591 * | number592 *593 * BINOP := '*' | '/' | '%'594 * | '+' | '-'595 * | '<<' | '>>'596 * | '<' | '>' | '<=' | '>='597 * | '==' | '!='598 * | '&' | '^' | '|'599 * | '&&' | '||'600 *601 * The normal C order of precedence is supported.602 *603 *604 * External Entry Points:605 *606 * ParseIfExpression parse a string for #if607 */608 609 /* $Header: /code/makedepend/ifparser.c,v 1.2 2004/04/20 19:50:26 doj Exp $ */610 611 #include "ifparser.h"612 #include <ctype.h>613 #include <stdlib.h>614 #include <string.h>615 616 /****************************************************************************617 Internal Macros and Utilities for Parser618 ****************************************************************************/619 620 #define DO(val) if (!(val)) return NULL621 #define CALLFUNC(ggg,fff) (*((ggg)->funcs.fff))622 #define SKIPSPACE(ccc) while (isspace(*ccc)) ccc++623 #define isvarfirstletter(ccc) (isalpha(ccc) || (ccc) == '_')624 625 626 static const char *627 parse_variable (IfParser *g, const char *cp, const char **varp)628 {629 SKIPSPACE (cp);630 631 if (!isvarfirstletter (*cp))632 return CALLFUNC(g, handle_error) (g, cp, "variable name");633 634 *varp = cp;635 /* EMPTY */636 for (cp++; isalnum(*cp) || *cp == '_'; cp++) ;637 return cp;638 }639 640 641 static const char *642 parse_number (IfParser *g, const char *cp, long *valp)643 {644 long base = 10;645 SKIPSPACE (cp);646 647 if (!isdigit(*cp))648 return CALLFUNC(g, handle_error) (g, cp, "number");649 650 *valp = 0;651 652 if (*cp == '0') {653 cp++;654 if ((*cp == 'x') || (*cp == 'X')) {655 base = 16;656 cp++;657 } else {658 base = 8;659 }660 }661 662 /* Ignore overflows and assume ASCII, what source is usually written in */663 while (1) {664 int increment = -1;665 if (base == 8) {666 if ((*cp >= '0') && (*cp <= '7'))667 increment = *cp++ - '0';668 } else if (base == 16) {669 if ((*cp >= '0') && (*cp <= '9'))670 increment = *cp++ - '0';671 else if ((*cp >= 'A') && (*cp <= 'F'))672 increment = *cp++ - ('A' - 10);673 else if ((*cp >= 'a') && (*cp <= 'f'))674 increment = *cp++ - ('a' - 10);675 } else { /* Decimal */676 if ((*cp >= '0') && (*cp <= '9'))677 increment = *cp++ - '0';678 }679 if (increment < 0)680 break;681 *valp = (*valp * base) + increment;682 }683 684 /* Skip trailing qualifiers */685 while (*cp == 'U' || *cp == 'u' || *cp == 'L' || *cp == 'l') cp++;686 return cp;687 }688 689 static const char *690 parse_character (IfParser *g, const char *cp, long *valp)691 {692 char val;693 694 SKIPSPACE (cp);695 if (*cp == '\\')696 switch (cp[1]) {697 case 'n': val = '\n'; break;698 case 't': val = '\t'; break;699 case 'v': val = '\v'; break;700 case 'b': val = '\b'; break;701 case 'r': val = '\r'; break;702 case 'f': val = '\f'; break;703 case 'a': val = '\a'; break;704 case '\\': val = '\\'; break;705 case '?': val = '\?'; break;706 case '\'': val = '\''; break;707 case '\"': val = '\"'; break;708 case 'x': val = (char) strtol (cp + 2, NULL, 16); break;709 default: val = (char) strtol (cp + 1, NULL, 8); break;710 }711 else712 val = *cp;713 while (*cp != '\'') cp++;714 *valp = (long) val;715 return cp;716 }717 718 static const char *719 parse_value (IfParser *g, const char *cp, long *valp)720 {721 const char *var, *varend;722 723 *valp = 0;724 725 SKIPSPACE (cp);726 if (!*cp)727 return cp;728 729 switch (*cp) {730 case '(':731 DO (cp = ParseIfExpression (g, cp + 1, valp));732 SKIPSPACE (cp);733 if (*cp != ')')734 return CALLFUNC(g, handle_error) (g, cp, ")");735 736 return cp + 1; /* skip the right paren */737 738 case '!':739 DO (cp = parse_value (g, cp + 1, valp));740 *valp = !(*valp);741 return cp;742 743 case '-':744 DO (cp = parse_value (g, cp + 1, valp));745 *valp = -(*valp);746 return cp;747 748 case '+':749 DO (cp = parse_value (g, cp + 1, valp));750 return cp;751 752 case '~':753 DO (cp = parse_value (g, cp + 1, valp));754 *valp = ~(*valp);755 return cp;756 757 case '#':758 DO (cp = parse_variable (g, cp + 1, &var));759 SKIPSPACE (cp);760 if (*cp != '(')761 return CALLFUNC(g, handle_error) (g, cp, "(");762 do {763 DO (cp = parse_variable (g, cp + 1, &var));764 SKIPSPACE (cp);765 } while (*cp && *cp != ')');766 if (*cp != ')')767 return CALLFUNC(g, handle_error) (g, cp, ")");768 *valp = 1; /* XXX */769 return cp + 1;770 771 case '\'':772 DO (cp = parse_character (g, cp + 1, valp));773 if (*cp != '\'')774 return CALLFUNC(g, handle_error) (g, cp, "'");775 return cp + 1;776 777 case 'd':778 if (strncmp (cp, "defined", 7) == 0 && !isalnum(cp[7])) {779 int paren = 0;780 int len;781 782 cp += 7;783 SKIPSPACE (cp);784 if (*cp == '(') {785 paren = 1;786 cp++;787 }788 DO (cp = parse_variable (g, cp, &var));789 len = cp - var;790 SKIPSPACE (cp);791 if (paren && *cp != ')')792 return CALLFUNC(g, handle_error) (g, cp, ")");793 *valp = (*(g->funcs.eval_defined)) (g, var, len);794 return cp + paren; /* skip the right paren */795 }796 /* fall out */797 }798 799 if (isdigit(*cp)) {800 DO (cp = parse_number (g, cp, valp));801 } else if (!isvarfirstletter(*cp))802 return CALLFUNC(g, handle_error) (g, cp, "variable or number");803 else {804 DO (cp = parse_variable (g, cp, &var));805 varend = cp;806 SKIPSPACE(cp);807 if (*cp != '(') {808 *valp = (*(g->funcs.eval_variable)) (g, var, varend - var);809 } else {810 do {811 long dummy;812 DO (cp = ParseIfExpression (g, cp + 1, &dummy));813 SKIPSPACE(cp);814 if (*cp == ')')815 break;816 if (*cp != ',')817 return CALLFUNC(g, handle_error) (g, cp, ",");818 } while (1);819 820 *valp = 1; /* XXX */821 cp++;822 }823 }824 825 return cp;826 }827 828 829 830 static const char *831 parse_product (IfParser *g, const char *cp, long *valp)832 {833 long rightval;834 835 DO (cp = parse_value (g, cp, valp));836 SKIPSPACE (cp);837 838 switch (*cp) {839 case '*':840 DO (cp = parse_product (g, cp + 1, &rightval));841 *valp = (*valp * rightval);842 break;843 844 case '/':845 DO (cp = parse_product (g, cp + 1, &rightval));846 *valp = (*valp / rightval);847 break;848 849 case '%':850 DO (cp = parse_product (g, cp + 1, &rightval));851 *valp = (*valp % rightval);852 break;853 }854 return cp;855 }856 857 858 static const char *859 parse_sum (IfParser *g, const char *cp, long *valp)860 {861 long rightval;862 863 DO (cp = parse_product (g, cp, valp));864 SKIPSPACE (cp);865 866 switch (*cp) {867 case '+':868 DO (cp = parse_sum (g, cp + 1, &rightval));869 *valp = (*valp + rightval);870 break;871 872 case '-':873 DO (cp = parse_sum (g, cp + 1, &rightval));874 *valp = (*valp - rightval);875 break;876 }877 return cp;878 }879 880 881 static const char *882 parse_shift (IfParser *g, const char *cp, long *valp)883 {884 long rightval;885 886 DO (cp = parse_sum (g, cp, valp));887 SKIPSPACE (cp);888 889 switch (*cp) {890 case '<':891 if (cp[1] == '<') {892 DO (cp = parse_shift (g, cp + 2, &rightval));893 *valp = (*valp << rightval);894 }895 break;896 897 case '>':898 if (cp[1] == '>') {899 DO (cp = parse_shift (g, cp + 2, &rightval));900 *valp = (*valp >> rightval);901 }902 break;903 }904 return cp;905 }906 907 908 static const char *909 parse_inequality (IfParser *g, const char *cp, long *valp)910 {911 long rightval;912 913 DO (cp = parse_shift (g, cp, valp));914 SKIPSPACE (cp);915 916 switch (*cp) {917 case '<':918 if (cp[1] == '=') {919 DO (cp = parse_inequality (g, cp + 2, &rightval));920 *valp = (*valp <= rightval);921 } else {922 DO (cp = parse_inequality (g, cp + 1, &rightval));923 *valp = (*valp < rightval);924 }925 break;926 927 case '>':928 if (cp[1] == '=') {929 DO (cp = parse_inequality (g, cp + 2, &rightval));930 *valp = (*valp >= rightval);931 } else {932 DO (cp = parse_inequality (g, cp + 1, &rightval));933 *valp = (*valp > rightval);934 }935 break;936 }937 return cp;938 }939 940 941 static const char *942 parse_equality (IfParser *g, const char *cp, long *valp)943 {944 long rightval;945 946 DO (cp = parse_inequality (g, cp, valp));947 SKIPSPACE (cp);948 949 switch (*cp) {950 case '=':951 if (cp[1] == '=')952 cp++;953 DO (cp = parse_equality (g, cp + 1, &rightval));954 *valp = (*valp == rightval);955 break;956 957 case '!':958 if (cp[1] != '=')959 break;960 DO (cp = parse_equality (g, cp + 2, &rightval));961 *valp = (*valp != rightval);962 break;963 }964 return cp;965 }966 967 968 static const char *969 parse_band (IfParser *g, const char *cp, long *valp)970 {971 long rightval;972 973 DO (cp = parse_equality (g, cp, valp));974 SKIPSPACE (cp);975 976 switch (*cp) {977 case '&':978 if (cp[1] != '&') {979 DO (cp = parse_band (g, cp + 1, &rightval));980 *valp = (*valp & rightval);981 }982 break;983 }984 return cp;985 }986 987 988 static const char *989 parse_bxor (IfParser *g, const char *cp, long *valp)990 {991 long rightval;992 993 DO (cp = parse_band (g, cp, valp));994 SKIPSPACE (cp);995 996 switch (*cp) {997 case '^':998 DO (cp = parse_bxor (g, cp + 1, &rightval));999 *valp = (*valp ^ rightval);1000 break;1001 }1002 return cp;1003 }1004 1005 1006 static const char *1007 parse_bor (IfParser *g, const char *cp, long *valp)1008 {1009 long rightval;1010 1011 DO (cp = parse_bxor (g, cp, valp));1012 SKIPSPACE (cp);1013 1014 switch (*cp) {1015 case '|':1016 if (cp[1] != '|') {1017 DO (cp = parse_bor (g, cp + 1, &rightval));1018 *valp = (*valp | rightval);1019 }1020 break;1021 }1022 return cp;1023 }1024 1025 1026 static const char *1027 parse_land (IfParser *g, const char *cp, long *valp)1028 {1029 long rightval;1030 1031 DO (cp = parse_bor (g, cp, valp));1032 SKIPSPACE (cp);1033 1034 switch (*cp) {1035 case '&':1036 if (cp[1] != '&')1037 return CALLFUNC(g, handle_error) (g, cp, "&&");1038 DO (cp = parse_land (g, cp + 2, &rightval));1039 *valp = (*valp && rightval);1040 break;1041 }1042 return cp;1043 }1044 1045 1046 static const char *1047 parse_lor (IfParser *g, const char *cp, long *valp)1048 {1049 long rightval;1050 1051 DO (cp = parse_land (g, cp, valp));1052 SKIPSPACE (cp);1053 1054 switch (*cp) {1055 case '|':1056 if (cp[1] != '|')1057 return CALLFUNC(g, handle_error) (g, cp, "||");1058 DO (cp = parse_lor (g, cp + 2, &rightval));1059 *valp = (*valp || rightval);1060 break;1061 }1062 return cp;1063 }1064 1065 1066 static const char *1067 parse_cond(IfParser *g, const char *cp, long *valp)1068 {1069 long trueval, falseval;1070 1071 DO (cp = parse_lor (g, cp, valp));1072 SKIPSPACE (cp);1073 1074 switch (*cp) {1075 case '?':1076 DO (cp = parse_cond (g, cp + 1, &trueval));1077 SKIPSPACE (cp);1078 if (*cp != ':')1079 return CALLFUNC(g, handle_error) (g, cp, ":");1080 DO (cp = parse_cond (g, cp + 1, &falseval));1081 *valp = (*valp ? trueval : falseval);1082 break;1083 }1084 return cp;1085 }1086 1087 1088 /****************************************************************************1089 External Entry Points1090 ****************************************************************************/1091 1092 const char *1093 ParseIfExpression (IfParser *g, const char *cp, long *valp)1094 {1095 return parse_cond (g, cp, valp);1096 }