Ignore:
Timestamp:
Jun 17, 2012, 10:45:31 PM (13 years ago)
Author:
bird
Message:

kmk: Merged in changes from GNU make 3.82. Previous GNU make base version was gnumake-2008-10-28-CVS.

Location:
trunk/src/kmk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk

    • Property svn:ignore
      •  

        old new  
        1313stamp-*
        1414makebook*
         15
        1516.*gdbinit
         17.gdb_history
         18
        1619*.dep
        1720*.dvi
         
        3134*.pg
        3235*.pgs
         36
        3337README
        3438README.DOS
        3539README.W32
         40README.OS2
        3641aclocal.m4
        3742autom4te.cache
         
        5257config.h.W32
        5358config.h-vms
         59
        5460loadavg
        5561loadavg.c
        5662make
         63
        5764.deps
        5865.dep_segment
         66ID
         67TAGS
         68
        5969_*
        6070sun4
         
        7282sol2
        7383i486-linux
         84
        7485customs
         86
        7587install-sh
        7688mkinstalldirs
         89
         90.directive.asc
  • trunk/src/kmk/function.c

    r2574 r2591  
    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
     
    514514  unsigned int idx;
    515515
    516 #ifndef CONFIG_WITH_ALLOC_CACHES
    517   chain = multi_glob (parse_file_seq
    518                       (&line, '\0', sizeof (struct nameseq),
    519                        /* We do not want parse_file_seq to strip `./'s.
    520                           That would break examples like:
    521                           $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)).  */
    522                        0),
    523                       sizeof (struct nameseq));
    524 #else  /* CONFIG_WITH_ALLOC_CACHES */
    525   chain = multi_glob (parse_file_seq
    526                       (&line, '\0', &nameseq_cache,
    527                        /* We do not want parse_file_seq to strip `./'s.
    528                           That would break examples like:
    529                           $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)).  */
    530                        0),
    531                       &nameseq_cache);
    532 #endif /* CONFIG_WITH_ALLOC_CACHES */
     516  chain = PARSE_FILE_SEQ (&line, struct nameseq, '\0', NULL,
     517                          /* We do not want parse_file_seq to strip `./'s.
     518                             That would break examples like:
     519                             $(patsubst ./%.c,obj/%.o,$(wildcard ./?*.c)).  */
     520                          PARSEFS_NOSTRIP|PARSEFS_NOCACHE|PARSEFS_EXISTS);
    533521
    534522  if (result == 0)
     
    541529  while (chain != 0)
    542530    {
    543       const char *name = chain->name;
    544       unsigned int len = strlen (name);
    545 
    546531      struct nameseq *next = chain->next;
     532      unsigned int len = strlen (chain->name);
     533
     534      if (idx + len + 1 > length)
     535        {
     536          length += (len + 1) * 2;
     537          result = xrealloc (result, length);
     538        }
     539      memcpy (&result[idx], chain->name, len);
     540      idx += len;
     541      result[idx++] = ' ';
     542
     543      /* Because we used PARSEFS_NOCACHE above, we have to free() NAME.  */
     544      free ((char *)chain->name);
    547545#ifndef CONFIG_WITH_ALLOC_CACHES
    548546      free (chain);
     
    551549#endif
    552550      chain = next;
    553 
    554       /* multi_glob will pass names without globbing metacharacters
    555          through as is, but we want only files that actually exist.  */
    556       if (file_exists_p (name))
    557         {
    558           if (idx + len + 1 > length)
    559             {
    560               length += (len + 1) * 2;
    561               result = xrealloc (result, length);
    562             }
    563           memcpy (&result[idx], name, len);
    564           idx += len;
    565           result[idx++] = ' ';
    566         }
    567551    }
    568552
     
    13461330
    13471331      free (var->value);
    1348       var->value = savestring (p, len);
     1332      var->value = xstrndup (p, len);
    13491333
    13501334      result = allocated_variable_expand (body);
     
    22202204
    22212205void
    2222 windows32_openpipe (int *pipedes, int *pid_p, char **command_argv, char **envp)
     2206windows32_openpipe (int *pipedes, pid_t *pid_p, char **command_argv, char **envp)
    22232207{
    22242208  SECURITY_ATTRIBUTES saAttr;
     
    22412225                      TRUE,
    22422226                      DUPLICATE_SAME_ACCESS) == FALSE) {
    2243     fatal (NILF, _("create_child_process: DuplicateHandle(In) failed (e=%ld)\n"),
     2227    fatal (NILF, _("windows32_openpipe(): DuplicateHandle(In) failed (e=%ld)\n"),
    22442228           GetLastError());
    22452229
     
    22522236                      TRUE,
    22532237                      DUPLICATE_SAME_ACCESS) == FALSE) {
    2254     fatal (NILF, _("create_child_process: DuplicateHandle(Err) failed (e=%ld)\n"),
     2238    fatal (NILF, _("windows32_open_pipe(): DuplicateHandle(Err) failed (e=%ld)\n"),
    22552239           GetLastError());
    22562240  }
     
    22622246
    22632247  if (!hProcess)
    2264     fatal (NILF, _("windows32_openpipe (): process_init_fd() failed\n"));
     2248    fatal (NILF, _("windows32_openpipe(): process_init_fd() failed\n"));
    22652249
    22662250  /* make sure that CreateProcess() has Path it needs */
    22672251  sync_Path_environment();
     2252  /* `sync_Path_environment' may realloc `environ', so take note of
     2253     the new value.  */
     2254  envp = environ;
    22682255
    22692256  if (!process_begin(hProcess, command_argv, envp, command_argv[0], NULL)) {
     
    22722259
    22732260    /* set the pid for returning to caller */
    2274     *pid_p = (int) hProcess;
     2261    *pid_p = (pid_t) hProcess;
    22752262
    22762263  /* set up to read data from child */
    2277   pipedes[0] = _open_osfhandle((long) hChildOutRd, O_RDONLY);
     2264  pipedes[0] = _open_osfhandle((intptr_t) hChildOutRd, O_RDONLY);
    22782265
    22792266  /* this will be closed almost right away */
    2280   pipedes[1] = _open_osfhandle((long) hChildOutWr, O_APPEND);
     2267  pipedes[1] = _open_osfhandle((intptr_t) hChildOutWr, O_APPEND);
    22812268  } else {
    22822269    /* reap/cleanup the failed process */
     
    22932280    /* set status for return */
    22942281    pipedes[0] = pipedes[1] = -1;
    2295     *pid_p = -1;
     2282    *pid_p = (pid_t)-1;
    22962283  }
    22972284}
     
    23662353#ifndef _AMIGA
    23672354static char *
    2368 func_shell (char *o, char **argv, const char *funcname UNUSED)
     2355func_shell (char * volatile o, char **argv, const char *funcname UNUSED)
    23692356{
    23702357  char *batch_filename = NULL;
     
    23742361#endif
    23752362  char **command_argv;
    2376   const char *error_prefix;
     2363  const char * volatile error_prefix; /* bird: this volatile and the 'o' one, is for shutting up gcc warnings */
    23772364  char **envp;
    23782365  int pipedes[2];
    2379   int pid;
     2366  pid_t pid;
    23802367
    23812368#ifndef __MSDOS__
     
    24672454      free (command_argv);
    24682455
    2469       /* Close the write side of the pipe.  */
    2470 # ifdef _MSC_VER /* Avoid annoying msvcrt when debugging. (bird) */
    2471       if (pipedes[1] != -1)
    2472 # endif
    2473       close (pipedes[1]);
     2456      /* Close the write side of the pipe.  We test for -1, since
     2457         pipedes[1] is -1 on MS-Windows, and some versions of MS
     2458         libraries barf when `close' is called with -1.  */
     2459      if (pipedes[1] >= 0)
     2460        close (pipedes[1]);
    24742461#endif
    24752462
     
    34423429
    34433430
     3431#ifdef HAVE_DOS_PATHS
     3432#define IS_ABSOLUTE(n) (n[0] && n[1] == ':')
     3433#define ROOT_LEN 3
     3434#else
     3435#define IS_ABSOLUTE(n) (n[0] == '/')
     3436#define ROOT_LEN 1
     3437#endif
     3438
    34443439/* Return the absolute name of file NAME which does not contain any `.',
    34453440   `..' components nor any repeated path separators ('/').   */
     
    34533448  char *dest;
    34543449  const char *start, *end, *apath_limit;
     3450  unsigned long root_len = ROOT_LEN;
    34553451
    34563452  if (name[0] == '\0' || apath == NULL)
     
    34793475  apath_limit = apath + GET_PATH_MAX;
    34803476
    3481 #ifdef HAVE_DOS_PATHS /* bird added this */
    3482   if (isalpha(name[0]) && name[1] == ':')
    3483     {
    3484       /* drive spec */
    3485       apath[0] = toupper(name[0]);
    3486       apath[1] = ':';
    3487       apath[2] = '/';
    3488       name += 2;
    3489     }
    3490   else
    3491 #endif /* HAVE_DOS_PATHS */
    3492   if (name[0] != '/')
     3477  if (!IS_ABSOLUTE(name))
    34933478    {
    34943479      /* It is unlikely we would make it until here but just to make sure. */
     
    34983483      strcpy (apath, starting_directory);
    34993484
     3485#ifdef HAVE_DOS_PATHS
     3486      if (IS_PATHSEP(name[0]))
     3487        {
     3488          if (IS_PATHSEP(name[1]))
     3489            {
     3490              /* A UNC.  Don't prepend a drive letter.  */
     3491              apath[0] = name[0];
     3492              apath[1] = name[1];
     3493              root_len = 2;
     3494            }
     3495          /* We have /foo, an absolute file name except for the drive
     3496             letter.  Assume the missing drive letter is the current
     3497             drive, which we can get if we remove from starting_directory
     3498             everything past the root directory.  */
     3499          apath[root_len] = '\0';
     3500        }
     3501#endif
     3502
    35003503      dest = strchr (apath, '\0');
    35013504    }
    35023505  else
    35033506    {
    3504       apath[0] = '/';
    3505       dest = apath + 1;
     3507      strncpy (apath, name, root_len);
     3508      apath[root_len] = '\0';
     3509      dest = apath + root_len;
     3510      /* Get past the root, since we already copied it.  */
     3511      name += root_len;
     3512#ifdef HAVE_DOS_PATHS
     3513      if (!IS_PATHSEP(apath[2]))
     3514        {
     3515          /* Convert d:foo into d:./foo and increase root_len.  */
     3516          apath[2] = '.';
     3517          apath[3] = '/';
     3518          dest++;
     3519          root_len++;
     3520          /* strncpy above copied one character too many.  */
     3521          name--;
     3522        }
     3523      else
     3524        apath[2] = '/'; /* make sure it's a forward slash */
     3525#endif
    35063526    }
    35073527
     
    35113531
    35123532      /* Skip sequence of multiple path-separators.  */
    3513       while (*start == '/')
     3533      while (IS_PATHSEP(*start))
    35143534        ++start;
    35153535
    35163536      /* Find end of path component.  */
    3517       for (end = start; *end != '\0' && *end != '/'; ++end)
     3537      for (end = start; *end != '\0' && !IS_PATHSEP(*end); ++end)
    35183538        ;
    35193539
     
    35273547        {
    35283548          /* Back up to previous component, ignore if at root already.  */
    3529           if (dest > apath + 1)
    3530             while ((--dest)[-1] != '/');
     3549          if (dest > apath + root_len)
     3550            for (--dest; !IS_PATHSEP(dest[-1]); --dest);
    35313551        }
    35323552      else
    35333553        {
    3534           if (dest[-1] != '/')
     3554          if (!IS_PATHSEP(dest[-1]))
    35353555            *dest++ = '/';
    35363556
     
    35463566
    35473567  /* Unless it is root strip trailing separator.  */
    3548 #ifdef HAVE_DOS_PATHS /* bird (is this correct? what about UNC?) */
    3549   if (dest > apath + 1 + (apath[0] != '/') && dest[-1] == '/')
    3550 #else
    3551   if (dest > apath + 1 && dest[-1] == '/')
    3552 #endif
     3568  if (dest > apath + root_len && IS_PATHSEP(dest[-1]))
    35533569    --dest;
    35543570
     
    35673583  int doneany = 0;
    35683584  unsigned int len = 0;
     3585#ifndef HAVE_REALPATH
     3586  struct stat st;
     3587#endif
    35693588  PATH_VAR (in);
    35703589  PATH_VAR (out);
     
    35813600              realpath (in, out)
    35823601#else
    3583               abspath (in, out)
     3602              abspath (in, out) && stat (out, &st) == 0
    35843603#endif
    35853604             )
Note: See TracChangeset for help on using the changeset viewer.