Ignore:
Timestamp:
Jun 20, 2012, 12:44:52 AM (13 years ago)
Author:
bird
Message:

gnumake/current -> 3.82-cvs.

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  
    11/* Builtin function expansion for GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    4 Foundation, Inc.
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
     42010 Free Software Foundation, Inc.
    55This file is part of GNU Make.
    66
     
    362362  unsigned int idx;
    363363
    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);
    371369
    372370  if (result == 0)
     
    379377  while (chain != 0)
    380378    {
    381       const char *name = chain->name;
    382       unsigned int len = strlen (name);
    383 
    384379      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);
    385393      free (chain);
    386394      chain = next;
    387 
    388       /* multi_glob will pass names without globbing metacharacters
    389          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         }
    401395    }
    402396
     
    861855
    862856      free (var->value);
    863       var->value = savestring (p, len);
     857      var->value = xstrndup (p, len);
    864858
    865859      result = allocated_variable_expand (body);
     
    14481442
    14491443void
    1450 windows32_openpipe (int *pipedes, int *pid_p, char **command_argv, char **envp)
     1444windows32_openpipe (int *pipedes, pid_t *pid_p, char **command_argv, char **envp)
    14511445{
    14521446  SECURITY_ATTRIBUTES saAttr;
     
    14691463                      TRUE,
    14701464                      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"),
    14721466           GetLastError());
    14731467
     
    14801474                      TRUE,
    14811475                      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"),
    14831477           GetLastError());
    14841478  }
     
    14901484
    14911485  if (!hProcess)
    1492     fatal (NILF, _("windows32_openpipe (): process_init_fd() failed\n"));
     1486    fatal (NILF, _("windows32_openpipe(): process_init_fd() failed\n"));
    14931487
    14941488  /* make sure that CreateProcess() has Path it needs */
    14951489  sync_Path_environment();
     1490  /* `sync_Path_environment' may realloc `environ', so take note of
     1491     the new value.  */
     1492  envp = environ;
    14961493
    14971494  if (!process_begin(hProcess, command_argv, envp, command_argv[0], NULL)) {
     
    15001497
    15011498    /* set the pid for returning to caller */
    1502     *pid_p = (int) hProcess;
     1499    *pid_p = (pid_t) hProcess;
    15031500
    15041501  /* 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);
    15061503
    15071504  /* 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);
    15091506  } else {
    15101507    /* reap/cleanup the failed process */
     
    15211518    /* set status for return */
    15221519    pipedes[0] = pipedes[1] = -1;
    1523     *pid_p = -1;
     1520    *pid_p = (pid_t)-1;
    15241521  }
    15251522}
     
    16051602  char **envp;
    16061603  int pipedes[2];
    1607   int pid;
     1604  pid_t pid;
    16081605
    16091606#ifndef __MSDOS__
     
    16951692      free (command_argv);
    16961693
    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]);
    16991699#endif
    17001700
     
    18871887
    18881888
     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
    18891897/* Return the absolute name of file NAME which does not contain any `.',
    18901898   `..' components nor any repeated path separators ('/').   */
     
    18951903  char *dest;
    18961904  const char *start, *end, *apath_limit;
     1905  unsigned long root_len = ROOT_LEN;
    18971906
    18981907  if (name[0] == '\0' || apath == NULL)
     
    19011910  apath_limit = apath + GET_PATH_MAX;
    19021911
    1903   if (name[0] != '/')
     1912  if (!IS_ABSOLUTE(name))
    19041913    {
    19051914      /* It is unlikely we would make it until here but just to make sure. */
     
    19091918      strcpy (apath, starting_directory);
    19101919
     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
    19111938      dest = strchr (apath, '\0');
    19121939    }
    19131940  else
    19141941    {
    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
    19171961    }
    19181962
     
    19221966
    19231967      /* Skip sequence of multiple path-separators.  */
    1924       while (*start == '/')
     1968      while (IS_PATHSEP(*start))
    19251969        ++start;
    19261970
    19271971      /* Find end of path component.  */
    1928       for (end = start; *end != '\0' && *end != '/'; ++end)
     1972      for (end = start; *end != '\0' && !IS_PATHSEP(*end); ++end)
    19291973        ;
    19301974
     
    19381982        {
    19391983          /* 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);
    19421986        }
    19431987      else
    19441988        {
    1945           if (dest[-1] != '/')
     1989          if (!IS_PATHSEP(dest[-1]))
    19461990            *dest++ = '/';
    19471991
     
    19562000
    19572001  /* Unless it is root strip trailing separator.  */
    1958   if (dest > apath + 1 && dest[-1] == '/')
     2002  if (dest > apath + root_len && IS_PATHSEP(dest[-1]))
    19592003    --dest;
    19602004
     
    19732017  int doneany = 0;
    19742018  unsigned int len = 0;
     2019#ifndef HAVE_REALPATH
     2020  struct stat st;
     2021#endif
    19752022  PATH_VAR (in);
    19762023  PATH_VAR (out);
     
    19872034              realpath (in, out)
    19882035#else
    1989               abspath (in, out)
     2036              abspath (in, out) && stat (out, &st) == 0
    19902037#endif
    19912038             )
Note: See TracChangeset for help on using the changeset viewer.