VirtualBox

Changeset 1459 in kBuild


Ignore:
Timestamp:
Mar 30, 2008 11:15:52 PM (17 years ago)
Author:
bird
Message:

Made $(abspathex path,cwd) work like $(abspath path) if cwd is empty. It used to just add a / to the path otherwise.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/function.c

    r1458 r1459  
    22802280
    22812281#ifdef CONFIG_WITH_ABSPATHEX
    2282 /* same as abspath except that the current path is given as the 2nd argument. */
     2282/* Same as abspath except that the current path may be given as the
     2283   2nd argument. */
    22832284static char *
    22842285func_abspathex (char *o, char **argv, const char *funcname UNUSED)
    22852286{
    2286   /* Expand the argument.  */
    2287   const char *p = argv[0];
    22882287  char *cwd = argv[1];
    2289   unsigned int cwd_len = ~0U;
    2290   char *path = 0;
    2291   int doneany = 0;
    2292   unsigned int len = 0;
    2293   PATH_VAR (in);
    2294   PATH_VAR (out);
    2295 
    2296   while ((path = find_next_token (&p, &len)) != 0)
    2297     {
    2298       if (len < GET_PATH_MAX)
     2288
     2289  /* cwd needs leading spaces chopped and may be optional,
     2290     in which case we're exactly like $(abspath ). */
     2291  while (isblank(*cwd))
     2292    cwd++;
     2293  if (!*cwd)
     2294    o = func_abspath (o, argv, funcname);
     2295  else
     2296    {
     2297      /* Expand the argument.  */
     2298      const char *p = argv[0];
     2299      unsigned int cwd_len = ~0U;
     2300      char *path = 0;
     2301      int doneany = 0;
     2302      unsigned int len = 0;
     2303      PATH_VAR (in);
     2304      PATH_VAR (out);
     2305   
     2306      while ((path = find_next_token (&p, &len)) != 0)
    22992307        {
     2308          if (len < GET_PATH_MAX)
     2309            {
    23002310#ifdef HAVE_DOS_PATHS
    2301           if (path[0] != '/' && path[0] != '\\' && (len < 2 || path[1] != ':') && cwd)
     2311              if (path[0] != '/' && path[0] != '\\' && (len < 2 || path[1] != ':') && cwd)
    23022312#else
    2303           if (path[0] != '/' && cwd)
    2304 #endif
    2305             {
    2306               /* relative path, prefix with cwd. */
    2307               if (cwd_len == ~0U)
    2308                 cwd_len = strlen (cwd);
    2309               if (cwd_len + len + 1 >= GET_PATH_MAX)
    2310                   continue;
    2311               memcpy (in, cwd, cwd_len);
    2312               in[cwd_len] = '/';
    2313               memcpy (in + cwd_len + 1, path, len);
    2314               in[cwd_len + len + 1] = '\0';
    2315             }
    2316           else
    2317             {
    2318               /* absolute path pass it as-is. */
    2319               memcpy (in, path, len);
    2320               in[len] = '\0';
    2321             }
    2322 
    2323           if (abspath (in, out))
    2324             {
    2325               o = variable_buffer_output (o, out, strlen (out));
    2326               o = variable_buffer_output (o, " ", 1);
    2327               doneany = 1;
     2313              if (path[0] != '/' && cwd)
     2314#endif
     2315                {
     2316                  /* relative path, prefix with cwd. */
     2317                  if (cwd_len == ~0U)
     2318                    cwd_len = strlen (cwd);
     2319                  if (cwd_len + len + 1 >= GET_PATH_MAX)
     2320                      continue;
     2321                  memcpy (in, cwd, cwd_len);
     2322                  in[cwd_len] = '/';
     2323                  memcpy (in + cwd_len + 1, path, len);
     2324                  in[cwd_len + len + 1] = '\0';
     2325                }
     2326              else
     2327                {
     2328                  /* absolute path pass it as-is. */
     2329                  memcpy (in, path, len);
     2330                  in[len] = '\0';
     2331                }
     2332   
     2333              if (abspath (in, out))
     2334                {
     2335                  o = variable_buffer_output (o, out, strlen (out));
     2336                  o = variable_buffer_output (o, " ", 1);
     2337                  doneany = 1;
     2338                }
    23282339            }
    23292340        }
    2330     }
    2331 
    2332   /* Kill last space.  */
    2333   if (doneany)
    2334     --o;
    2335 
    2336  return o;
     2341   
     2342      /* Kill last space.  */
     2343      if (doneany)
     2344        --o;
     2345    }
     2346 
     2347   return o;
    23372348}
    23382349#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette