Changeset 2596 for vendor/gnumake/current/function.c
- Timestamp:
- Jun 20, 2012, 12:44:52 AM (13 years ago)
- Location:
- vendor/gnumake/current
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/gnumake/current
- Property svn:ignore deleted
-
vendor/gnumake/current/function.c
r1989 r2596 1 1 /* Builtin function expansion for GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software4 Foundation, Inc.3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 2010 Free Software Foundation, Inc. 5 5 This file is part of GNU Make. 6 6 … … 362 362 unsigned int idx; 363 363 364 chain = multi_glob (parse_file_seq 365 (&line, '\0', sizeof (struct nameseq), 366 /* We do not want parse_file_seq to strip `./'s. 367 That would break examples like: 368 $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)). */ 369 0), 370 sizeof (struct nameseq)); 364 chain = PARSE_FILE_SEQ (&line, struct nameseq, '\0', NULL, 365 /* We do not want parse_file_seq to strip `./'s. 366 That would break examples like: 367 $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)). */ 368 PARSEFS_NOSTRIP|PARSEFS_NOCACHE|PARSEFS_EXISTS); 371 369 372 370 if (result == 0) … … 379 377 while (chain != 0) 380 378 { 381 const char *name = chain->name;382 unsigned int len = strlen (name);383 384 379 struct nameseq *next = chain->next; 380 unsigned int len = strlen (chain->name); 381 382 if (idx + len + 1 > length) 383 { 384 length += (len + 1) * 2; 385 result = xrealloc (result, length); 386 } 387 memcpy (&result[idx], chain->name, len); 388 idx += len; 389 result[idx++] = ' '; 390 391 /* Because we used PARSEFS_NOCACHE above, we have to free() NAME. */ 392 free ((char *)chain->name); 385 393 free (chain); 386 394 chain = next; 387 388 /* multi_glob will pass names without globbing metacharacters389 through as is, but we want only files that actually exist. */390 if (file_exists_p (name))391 {392 if (idx + len + 1 > length)393 {394 length += (len + 1) * 2;395 result = xrealloc (result, length);396 }397 memcpy (&result[idx], name, len);398 idx += len;399 result[idx++] = ' ';400 }401 395 } 402 396 … … 861 855 862 856 free (var->value); 863 var->value = savestring(p, len);857 var->value = xstrndup (p, len); 864 858 865 859 result = allocated_variable_expand (body); … … 1448 1442 1449 1443 void 1450 windows32_openpipe (int *pipedes, int *pid_p, char **command_argv, char **envp)1444 windows32_openpipe (int *pipedes, pid_t *pid_p, char **command_argv, char **envp) 1451 1445 { 1452 1446 SECURITY_ATTRIBUTES saAttr; … … 1469 1463 TRUE, 1470 1464 DUPLICATE_SAME_ACCESS) == FALSE) { 1471 fatal (NILF, _(" create_child_process: DuplicateHandle(In) failed (e=%ld)\n"),1465 fatal (NILF, _("windows32_openpipe(): DuplicateHandle(In) failed (e=%ld)\n"), 1472 1466 GetLastError()); 1473 1467 … … 1480 1474 TRUE, 1481 1475 DUPLICATE_SAME_ACCESS) == FALSE) { 1482 fatal (NILF, _(" create_child_process: DuplicateHandle(Err) failed (e=%ld)\n"),1476 fatal (NILF, _("windows32_open_pipe(): DuplicateHandle(Err) failed (e=%ld)\n"), 1483 1477 GetLastError()); 1484 1478 } … … 1490 1484 1491 1485 if (!hProcess) 1492 fatal (NILF, _("windows32_openpipe 1486 fatal (NILF, _("windows32_openpipe(): process_init_fd() failed\n")); 1493 1487 1494 1488 /* make sure that CreateProcess() has Path it needs */ 1495 1489 sync_Path_environment(); 1490 /* `sync_Path_environment' may realloc `environ', so take note of 1491 the new value. */ 1492 envp = environ; 1496 1493 1497 1494 if (!process_begin(hProcess, command_argv, envp, command_argv[0], NULL)) { … … 1500 1497 1501 1498 /* set the pid for returning to caller */ 1502 *pid_p = ( int) hProcess;1499 *pid_p = (pid_t) hProcess; 1503 1500 1504 1501 /* set up to read data from child */ 1505 pipedes[0] = _open_osfhandle(( long) hChildOutRd, O_RDONLY);1502 pipedes[0] = _open_osfhandle((intptr_t) hChildOutRd, O_RDONLY); 1506 1503 1507 1504 /* this will be closed almost right away */ 1508 pipedes[1] = _open_osfhandle(( long) hChildOutWr, O_APPEND);1505 pipedes[1] = _open_osfhandle((intptr_t) hChildOutWr, O_APPEND); 1509 1506 } else { 1510 1507 /* reap/cleanup the failed process */ … … 1521 1518 /* set status for return */ 1522 1519 pipedes[0] = pipedes[1] = -1; 1523 *pid_p = -1;1520 *pid_p = (pid_t)-1; 1524 1521 } 1525 1522 } … … 1605 1602 char **envp; 1606 1603 int pipedes[2]; 1607 int pid;1604 pid_t pid; 1608 1605 1609 1606 #ifndef __MSDOS__ … … 1695 1692 free (command_argv); 1696 1693 1697 /* Close the write side of the pipe. */ 1698 close (pipedes[1]); 1694 /* Close the write side of the pipe. We test for -1, since 1695 pipedes[1] is -1 on MS-Windows, and some versions of MS 1696 libraries barf when `close' is called with -1. */ 1697 if (pipedes[1] >= 0) 1698 close (pipedes[1]); 1699 1699 #endif 1700 1700 … … 1887 1887 1888 1888 1889 #ifdef HAVE_DOS_PATHS 1890 #define IS_ABSOLUTE(n) (n[0] && n[1] == ':') 1891 #define ROOT_LEN 3 1892 #else 1893 #define IS_ABSOLUTE(n) (n[0] == '/') 1894 #define ROOT_LEN 1 1895 #endif 1896 1889 1897 /* Return the absolute name of file NAME which does not contain any `.', 1890 1898 `..' components nor any repeated path separators ('/'). */ … … 1895 1903 char *dest; 1896 1904 const char *start, *end, *apath_limit; 1905 unsigned long root_len = ROOT_LEN; 1897 1906 1898 1907 if (name[0] == '\0' || apath == NULL) … … 1901 1910 apath_limit = apath + GET_PATH_MAX; 1902 1911 1903 if ( name[0] != '/')1912 if (!IS_ABSOLUTE(name)) 1904 1913 { 1905 1914 /* It is unlikely we would make it until here but just to make sure. */ … … 1909 1918 strcpy (apath, starting_directory); 1910 1919 1920 #ifdef HAVE_DOS_PATHS 1921 if (IS_PATHSEP(name[0])) 1922 { 1923 if (IS_PATHSEP(name[1])) 1924 { 1925 /* A UNC. Don't prepend a drive letter. */ 1926 apath[0] = name[0]; 1927 apath[1] = name[1]; 1928 root_len = 2; 1929 } 1930 /* We have /foo, an absolute file name except for the drive 1931 letter. Assume the missing drive letter is the current 1932 drive, which we can get if we remove from starting_directory 1933 everything past the root directory. */ 1934 apath[root_len] = '\0'; 1935 } 1936 #endif 1937 1911 1938 dest = strchr (apath, '\0'); 1912 1939 } 1913 1940 else 1914 1941 { 1915 apath[0] = '/'; 1916 dest = apath + 1; 1942 strncpy (apath, name, root_len); 1943 apath[root_len] = '\0'; 1944 dest = apath + root_len; 1945 /* Get past the root, since we already copied it. */ 1946 name += root_len; 1947 #ifdef HAVE_DOS_PATHS 1948 if (!IS_PATHSEP(apath[2])) 1949 { 1950 /* Convert d:foo into d:./foo and increase root_len. */ 1951 apath[2] = '.'; 1952 apath[3] = '/'; 1953 dest++; 1954 root_len++; 1955 /* strncpy above copied one character too many. */ 1956 name--; 1957 } 1958 else 1959 apath[2] = '/'; /* make sure it's a forward slash */ 1960 #endif 1917 1961 } 1918 1962 … … 1922 1966 1923 1967 /* Skip sequence of multiple path-separators. */ 1924 while ( *start == '/')1968 while (IS_PATHSEP(*start)) 1925 1969 ++start; 1926 1970 1927 1971 /* Find end of path component. */ 1928 for (end = start; *end != '\0' && *end != '/'; ++end)1972 for (end = start; *end != '\0' && !IS_PATHSEP(*end); ++end) 1929 1973 ; 1930 1974 … … 1938 1982 { 1939 1983 /* Back up to previous component, ignore if at root already. */ 1940 if (dest > apath + 1)1941 while ((--dest)[-1] != '/');1984 if (dest > apath + root_len) 1985 for (--dest; !IS_PATHSEP(dest[-1]); --dest); 1942 1986 } 1943 1987 else 1944 1988 { 1945 if ( dest[-1] != '/')1989 if (!IS_PATHSEP(dest[-1])) 1946 1990 *dest++ = '/'; 1947 1991 … … 1956 2000 1957 2001 /* Unless it is root strip trailing separator. */ 1958 if (dest > apath + 1 && dest[-1] == '/')2002 if (dest > apath + root_len && IS_PATHSEP(dest[-1])) 1959 2003 --dest; 1960 2004 … … 1973 2017 int doneany = 0; 1974 2018 unsigned int len = 0; 2019 #ifndef HAVE_REALPATH 2020 struct stat st; 2021 #endif 1975 2022 PATH_VAR (in); 1976 2023 PATH_VAR (out); … … 1987 2034 realpath (in, out) 1988 2035 #else 1989 abspath (in, out) 2036 abspath (in, out) && stat (out, &st) == 0 1990 2037 #endif 1991 2038 )
Note:
See TracChangeset
for help on using the changeset viewer.