Changeset 2591 for trunk/src/kmk/function.c
- Timestamp:
- Jun 17, 2012, 10:45:31 PM (13 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk
- Property svn:ignore
-
old new 13 13 stamp-* 14 14 makebook* 15 15 16 .*gdbinit 17 .gdb_history 18 16 19 *.dep 17 20 *.dvi … … 31 34 *.pg 32 35 *.pgs 36 33 37 README 34 38 README.DOS 35 39 README.W32 40 README.OS2 36 41 aclocal.m4 37 42 autom4te.cache … … 52 57 config.h.W32 53 58 config.h-vms 59 54 60 loadavg 55 61 loadavg.c 56 62 make 63 57 64 .deps 58 65 .dep_segment 66 ID 67 TAGS 68 59 69 _* 60 70 sun4 … … 72 82 sol2 73 83 i486-linux 84 74 85 customs 86 75 87 install-sh 76 88 mkinstalldirs 89 90 .directive.asc
-
- Property svn:ignore
-
trunk/src/kmk/function.c
r2574 r2591 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 … … 514 514 unsigned int idx; 515 515 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); 533 521 534 522 if (result == 0) … … 541 529 while (chain != 0) 542 530 { 543 const char *name = chain->name;544 unsigned int len = strlen (name);545 546 531 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); 547 545 #ifndef CONFIG_WITH_ALLOC_CACHES 548 546 free (chain); … … 551 549 #endif 552 550 chain = next; 553 554 /* multi_glob will pass names without globbing metacharacters555 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 }567 551 } 568 552 … … 1346 1330 1347 1331 free (var->value); 1348 var->value = savestring(p, len);1332 var->value = xstrndup (p, len); 1349 1333 1350 1334 result = allocated_variable_expand (body); … … 2220 2204 2221 2205 void 2222 windows32_openpipe (int *pipedes, int *pid_p, char **command_argv, char **envp)2206 windows32_openpipe (int *pipedes, pid_t *pid_p, char **command_argv, char **envp) 2223 2207 { 2224 2208 SECURITY_ATTRIBUTES saAttr; … … 2241 2225 TRUE, 2242 2226 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"), 2244 2228 GetLastError()); 2245 2229 … … 2252 2236 TRUE, 2253 2237 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"), 2255 2239 GetLastError()); 2256 2240 } … … 2262 2246 2263 2247 if (!hProcess) 2264 fatal (NILF, _("windows32_openpipe 2248 fatal (NILF, _("windows32_openpipe(): process_init_fd() failed\n")); 2265 2249 2266 2250 /* make sure that CreateProcess() has Path it needs */ 2267 2251 sync_Path_environment(); 2252 /* `sync_Path_environment' may realloc `environ', so take note of 2253 the new value. */ 2254 envp = environ; 2268 2255 2269 2256 if (!process_begin(hProcess, command_argv, envp, command_argv[0], NULL)) { … … 2272 2259 2273 2260 /* set the pid for returning to caller */ 2274 *pid_p = ( int) hProcess;2261 *pid_p = (pid_t) hProcess; 2275 2262 2276 2263 /* 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); 2278 2265 2279 2266 /* 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); 2281 2268 } else { 2282 2269 /* reap/cleanup the failed process */ … … 2293 2280 /* set status for return */ 2294 2281 pipedes[0] = pipedes[1] = -1; 2295 *pid_p = -1;2282 *pid_p = (pid_t)-1; 2296 2283 } 2297 2284 } … … 2366 2353 #ifndef _AMIGA 2367 2354 static char * 2368 func_shell (char * o, char **argv, const char *funcname UNUSED)2355 func_shell (char * volatile o, char **argv, const char *funcname UNUSED) 2369 2356 { 2370 2357 char *batch_filename = NULL; … … 2374 2361 #endif 2375 2362 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 */ 2377 2364 char **envp; 2378 2365 int pipedes[2]; 2379 int pid;2366 pid_t pid; 2380 2367 2381 2368 #ifndef __MSDOS__ … … 2467 2454 free (command_argv); 2468 2455 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 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]); 2474 2461 #endif 2475 2462 … … 3442 3429 3443 3430 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 3444 3439 /* Return the absolute name of file NAME which does not contain any `.', 3445 3440 `..' components nor any repeated path separators ('/'). */ … … 3453 3448 char *dest; 3454 3449 const char *start, *end, *apath_limit; 3450 unsigned long root_len = ROOT_LEN; 3455 3451 3456 3452 if (name[0] == '\0' || apath == NULL) … … 3479 3475 apath_limit = apath + GET_PATH_MAX; 3480 3476 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)) 3493 3478 { 3494 3479 /* It is unlikely we would make it until here but just to make sure. */ … … 3498 3483 strcpy (apath, starting_directory); 3499 3484 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 3500 3503 dest = strchr (apath, '\0'); 3501 3504 } 3502 3505 else 3503 3506 { 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 3506 3526 } 3507 3527 … … 3511 3531 3512 3532 /* Skip sequence of multiple path-separators. */ 3513 while ( *start == '/')3533 while (IS_PATHSEP(*start)) 3514 3534 ++start; 3515 3535 3516 3536 /* Find end of path component. */ 3517 for (end = start; *end != '\0' && *end != '/'; ++end)3537 for (end = start; *end != '\0' && !IS_PATHSEP(*end); ++end) 3518 3538 ; 3519 3539 … … 3527 3547 { 3528 3548 /* 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); 3531 3551 } 3532 3552 else 3533 3553 { 3534 if ( dest[-1] != '/')3554 if (!IS_PATHSEP(dest[-1])) 3535 3555 *dest++ = '/'; 3536 3556 … … 3546 3566 3547 3567 /* 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])) 3553 3569 --dest; 3554 3570 … … 3567 3583 int doneany = 0; 3568 3584 unsigned int len = 0; 3585 #ifndef HAVE_REALPATH 3586 struct stat st; 3587 #endif 3569 3588 PATH_VAR (in); 3570 3589 PATH_VAR (out); … … 3581 3600 realpath (in, out) 3582 3601 #else 3583 abspath (in, out) 3602 abspath (in, out) && stat (out, &st) == 0 3584 3603 #endif 3585 3604 )
Note:
See TracChangeset
for help on using the changeset viewer.