Deleted Added
full compact
var.c (236769) var.c (237578)
1/* $NetBSD: var.c,v 1.170 2012/06/04 20:34:20 sjg Exp $ */
1/* $NetBSD: var.c,v 1.171 2012/06/12 19:21:51 joerg Exp $ */
2
3/*
4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor.
9 *

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

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

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

64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE.
69 */
70
71#ifndef MAKE_NATIVE
72static char rcsid[] = "$NetBSD: var.c,v 1.170 2012/06/04 20:34:20 sjg Exp $";
72static char rcsid[] = "$NetBSD: var.c,v 1.171 2012/06/12 19:21:51 joerg Exp $";
73#else
74#include <sys/cdefs.h>
75#ifndef lint
76#if 0
77static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
78#else
73#else
74#include <sys/cdefs.h>
75#ifndef lint
76#if 0
77static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
78#else
79__RCSID("$NetBSD: var.c,v 1.170 2012/06/04 20:34:20 sjg Exp $");
79__RCSID("$NetBSD: var.c,v 1.171 2012/06/12 19:21:51 joerg Exp $");
80#endif
81#endif /* not lint */
82#endif
83
84/*-
85 * var.c --
86 * Variable-handling functions
87 *

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

1140 * added to the buffer before the next word).
1141 *
1142 * Side Effects:
1143 * The trimmed word is added to the buffer.
1144 *
1145 *-----------------------------------------------------------------------
1146 */
1147static Boolean
80#endif
81#endif /* not lint */
82#endif
83
84/*-
85 * var.c --
86 * Variable-handling functions
87 *

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

1140 * added to the buffer before the next word).
1141 *
1142 * Side Effects:
1143 * The trimmed word is added to the buffer.
1144 *
1145 *-----------------------------------------------------------------------
1146 */
1147static Boolean
1148VarHead(GNode *ctx __unused, Var_Parse_State *vpstate,
1148VarHead(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
1149 char *word, Boolean addSpace, Buffer *buf,
1150 void *dummy)
1151{
1152 char *slash;
1153
1154 slash = strrchr(word, '/');
1155 if (slash != NULL) {
1156 if (addSpace && vpstate->varSpace) {

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

1188 * added to the buffer before the next word).
1189 *
1190 * Side Effects:
1191 * The trimmed word is added to the buffer.
1192 *
1193 *-----------------------------------------------------------------------
1194 */
1195static Boolean
1149 char *word, Boolean addSpace, Buffer *buf,
1150 void *dummy)
1151{
1152 char *slash;
1153
1154 slash = strrchr(word, '/');
1155 if (slash != NULL) {
1156 if (addSpace && vpstate->varSpace) {

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

1188 * added to the buffer before the next word).
1189 *
1190 * Side Effects:
1191 * The trimmed word is added to the buffer.
1192 *
1193 *-----------------------------------------------------------------------
1194 */
1195static Boolean
1196VarTail(GNode *ctx __unused, Var_Parse_State *vpstate,
1196VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
1197 char *word, Boolean addSpace, Buffer *buf,
1198 void *dummy)
1199{
1200 char *slash;
1201
1202 if (addSpace && vpstate->varSpace) {
1203 Buf_AddByte(buf, vpstate->varSpace);
1204 }

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

1230 * added to the buffer before the next word).
1231 *
1232 * Side Effects:
1233 * The suffix from the word is placed in the buffer.
1234 *
1235 *-----------------------------------------------------------------------
1236 */
1237static Boolean
1197 char *word, Boolean addSpace, Buffer *buf,
1198 void *dummy)
1199{
1200 char *slash;
1201
1202 if (addSpace && vpstate->varSpace) {
1203 Buf_AddByte(buf, vpstate->varSpace);
1204 }

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

1230 * added to the buffer before the next word).
1231 *
1232 * Side Effects:
1233 * The suffix from the word is placed in the buffer.
1234 *
1235 *-----------------------------------------------------------------------
1236 */
1237static Boolean
1238VarSuffix(GNode *ctx __unused, Var_Parse_State *vpstate,
1238VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
1239 char *word, Boolean addSpace, Buffer *buf,
1240 void *dummy)
1241{
1242 char *dot;
1243
1244 dot = strrchr(word, '.');
1245 if (dot != NULL) {
1246 if (addSpace && vpstate->varSpace) {

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

1271 * added to the buffer before the next word).
1272 *
1273 * Side Effects:
1274 * The trimmed word is added to the buffer.
1275 *
1276 *-----------------------------------------------------------------------
1277 */
1278static Boolean
1239 char *word, Boolean addSpace, Buffer *buf,
1240 void *dummy)
1241{
1242 char *dot;
1243
1244 dot = strrchr(word, '.');
1245 if (dot != NULL) {
1246 if (addSpace && vpstate->varSpace) {

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

1271 * added to the buffer before the next word).
1272 *
1273 * Side Effects:
1274 * The trimmed word is added to the buffer.
1275 *
1276 *-----------------------------------------------------------------------
1277 */
1278static Boolean
1279VarRoot(GNode *ctx __unused, Var_Parse_State *vpstate,
1279VarRoot(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
1280 char *word, Boolean addSpace, Buffer *buf,
1281 void *dummy)
1282{
1283 char *dot;
1284
1285 if (addSpace && vpstate->varSpace) {
1286 Buf_AddByte(buf, vpstate->varSpace);
1287 }

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

1315 * word.
1316 *
1317 * Side Effects:
1318 * The word may be copied to the buffer.
1319 *
1320 *-----------------------------------------------------------------------
1321 */
1322static Boolean
1280 char *word, Boolean addSpace, Buffer *buf,
1281 void *dummy)
1282{
1283 char *dot;
1284
1285 if (addSpace && vpstate->varSpace) {
1286 Buf_AddByte(buf, vpstate->varSpace);
1287 }

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

1315 * word.
1316 *
1317 * Side Effects:
1318 * The word may be copied to the buffer.
1319 *
1320 *-----------------------------------------------------------------------
1321 */
1322static Boolean
1323VarMatch(GNode *ctx __unused, Var_Parse_State *vpstate,
1323VarMatch(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
1324 char *word, Boolean addSpace, Buffer *buf,
1325 void *pattern)
1326{
1327 if (DEBUG(VAR))
1328 fprintf(debug_file, "VarMatch [%s] [%s]\n", word, (char *)pattern);
1329 if (Str_Match(word, (char *)pattern)) {
1330 if (addSpace && vpstate->varSpace) {
1331 Buf_AddByte(buf, vpstate->varSpace);

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

1406 * word.
1407 *
1408 * Side Effects:
1409 * The word may be copied to the buffer.
1410 *
1411 *-----------------------------------------------------------------------
1412 */
1413static Boolean
1324 char *word, Boolean addSpace, Buffer *buf,
1325 void *pattern)
1326{
1327 if (DEBUG(VAR))
1328 fprintf(debug_file, "VarMatch [%s] [%s]\n", word, (char *)pattern);
1329 if (Str_Match(word, (char *)pattern)) {
1330 if (addSpace && vpstate->varSpace) {
1331 Buf_AddByte(buf, vpstate->varSpace);

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

1406 * word.
1407 *
1408 * Side Effects:
1409 * The word may be copied to the buffer.
1410 *
1411 *-----------------------------------------------------------------------
1412 */
1413static Boolean
1414VarNoMatch(GNode *ctx __unused, Var_Parse_State *vpstate,
1414VarNoMatch(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
1415 char *word, Boolean addSpace, Buffer *buf,
1416 void *pattern)
1417{
1418 if (!Str_Match(word, (char *)pattern)) {
1419 if (addSpace && vpstate->varSpace) {
1420 Buf_AddByte(buf, vpstate->varSpace);
1421 }
1422 addSpace = TRUE;

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

1443 * TRUE if a space is needed before more characters are added.
1444 *
1445 * Side Effects:
1446 * None.
1447 *
1448 *-----------------------------------------------------------------------
1449 */
1450static Boolean
1415 char *word, Boolean addSpace, Buffer *buf,
1416 void *pattern)
1417{
1418 if (!Str_Match(word, (char *)pattern)) {
1419 if (addSpace && vpstate->varSpace) {
1420 Buf_AddByte(buf, vpstate->varSpace);
1421 }
1422 addSpace = TRUE;

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

1443 * TRUE if a space is needed before more characters are added.
1444 *
1445 * Side Effects:
1446 * None.
1447 *
1448 *-----------------------------------------------------------------------
1449 */
1450static Boolean
1451VarSubstitute(GNode *ctx __unused, Var_Parse_State *vpstate,
1451VarSubstitute(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
1452 char *word, Boolean addSpace, Buffer *buf,
1453 void *patternp)
1454{
1455 int wordLen; /* Length of word */
1456 char *cp; /* General pointer */
1457 VarPattern *pattern = (VarPattern *)patternp;
1458
1459 wordLen = strlen(word);

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

1639 * TRUE if a space is needed before more characters are added.
1640 *
1641 * Side Effects:
1642 * None.
1643 *
1644 *-----------------------------------------------------------------------
1645 */
1646static Boolean
1452 char *word, Boolean addSpace, Buffer *buf,
1453 void *patternp)
1454{
1455 int wordLen; /* Length of word */
1456 char *cp; /* General pointer */
1457 VarPattern *pattern = (VarPattern *)patternp;
1458
1459 wordLen = strlen(word);

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

1639 * TRUE if a space is needed before more characters are added.
1640 *
1641 * Side Effects:
1642 * None.
1643 *
1644 *-----------------------------------------------------------------------
1645 */
1646static Boolean
1647VarRESubstitute(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
1647VarRESubstitute(GNode *ctx MAKE_ATTR_UNUSED,
1648 Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
1648 char *word, Boolean addSpace, Buffer *buf,
1649 void *patternp)
1650{
1651 VarREPattern *pat;
1652 int xrv;
1653 char *wp;
1654 char *rp;
1655 int added;

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

1779 * TRUE if a space is needed before more characters are added.
1780 *
1781 * Side Effects:
1782 * None.
1783 *
1784 *-----------------------------------------------------------------------
1785 */
1786static Boolean
1649 char *word, Boolean addSpace, Buffer *buf,
1650 void *patternp)
1651{
1652 VarREPattern *pat;
1653 int xrv;
1654 char *wp;
1655 char *rp;
1656 int added;

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

1780 * TRUE if a space is needed before more characters are added.
1781 *
1782 * Side Effects:
1783 * None.
1784 *
1785 *-----------------------------------------------------------------------
1786 */
1787static Boolean
1787VarLoopExpand(GNode *ctx __unused, Var_Parse_State *vpstate __unused,
1788VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSED,
1789 Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
1788 char *word, Boolean addSpace, Buffer *buf,
1789 void *loopp)
1790{
1791 VarLoop_t *loop = (VarLoop_t *)loopp;
1792 char *s;
1793 int slen;
1794
1795 if (word && *word) {

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

1822 * A string of all the words selected.
1823 *
1824 * Side Effects:
1825 * None.
1826 *
1827 *-----------------------------------------------------------------------
1828 */
1829static char *
1790 char *word, Boolean addSpace, Buffer *buf,
1791 void *loopp)
1792{
1793 VarLoop_t *loop = (VarLoop_t *)loopp;
1794 char *s;
1795 int slen;
1796
1797 if (word && *word) {

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

1824 * A string of all the words selected.
1825 *
1826 * Side Effects:
1827 * None.
1828 *
1829 *-----------------------------------------------------------------------
1830 */
1831static char *
1830VarSelectWords(GNode *ctx __unused, Var_Parse_State *vpstate,
1832VarSelectWords(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
1831 const char *str, VarSelectWords_t *seldata)
1832{
1833 Buffer buf; /* Buffer for the new string */
1834 Boolean addSpace; /* TRUE if need to add a space to the
1835 * buffer before adding the trimmed
1836 * word */
1837 char **av; /* word list */
1838 char *as; /* word list memory */

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

1897
1898
1899/*-
1900 * VarRealpath --
1901 * Replace each word with the result of realpath()
1902 * if successful.
1903 */
1904static Boolean
1833 const char *str, VarSelectWords_t *seldata)
1834{
1835 Buffer buf; /* Buffer for the new string */
1836 Boolean addSpace; /* TRUE if need to add a space to the
1837 * buffer before adding the trimmed
1838 * word */
1839 char **av; /* word list */
1840 char *as; /* word list memory */

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

1899
1900
1901/*-
1902 * VarRealpath --
1903 * Replace each word with the result of realpath()
1904 * if successful.
1905 */
1906static Boolean
1905VarRealpath(GNode *ctx __unused, Var_Parse_State *vpstate,
1907VarRealpath(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
1906 char *word, Boolean addSpace, Buffer *buf,
1908 char *word, Boolean addSpace, Buffer *buf,
1907 void *patternp __unused)
1909 void *patternp MAKE_ATTR_UNUSED)
1908{
1909 struct stat st;
1910 char rbuf[MAXPATHLEN];
1911 char *rp;
1912
1913 if (addSpace && vpstate->varSpace) {
1914 Buf_AddByte(buf, vpstate->varSpace);
1915 }

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

2122 * If flags is specified and the last character of the pattern is a
2123 * $ set the VAR_MATCH_END bit of flags.
2124 *
2125 * Side Effects:
2126 * None.
2127 *-----------------------------------------------------------------------
2128 */
2129static char *
1910{
1911 struct stat st;
1912 char rbuf[MAXPATHLEN];
1913 char *rp;
1914
1915 if (addSpace && vpstate->varSpace) {
1916 Buf_AddByte(buf, vpstate->varSpace);
1917 }

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

2124 * If flags is specified and the last character of the pattern is a
2125 * $ set the VAR_MATCH_END bit of flags.
2126 *
2127 * Side Effects:
2128 * None.
2129 *-----------------------------------------------------------------------
2130 */
2131static char *
2130VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate __unused,
2132VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
2131 int errnum, const char **tstr, int delim, int *flags,
2132 int *length, VarPattern *pattern)
2133{
2134 const char *cp;
2135 char *rstr;
2136 Buffer buf;
2137 int junk;
2138

--- 2056 unchanged lines hidden ---
2133 int errnum, const char **tstr, int delim, int *flags,
2134 int *length, VarPattern *pattern)
2135{
2136 const char *cp;
2137 char *rstr;
2138 Buffer buf;
2139 int junk;
2140

--- 2056 unchanged lines hidden ---