Mercurial > hg > CbC > CbC_gcc
comparison libiberty/argv.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Create and destroy argument vectors (argv's) | 1 /* Create and destroy argument vectors (argv's) |
2 Copyright (C) 1992-2017 Free Software Foundation, Inc. | 2 Copyright (C) 1992-2018 Free Software Foundation, Inc. |
3 Written by Fred Fish @ Cygnus Support | 3 Written by Fred Fish @ Cygnus Support |
4 | 4 |
5 This file is part of the libiberty library. | 5 This file is part of the libiberty library. |
6 Libiberty is free software; you can redistribute it and/or | 6 Libiberty is free software; you can redistribute it and/or |
7 modify it under the terms of the GNU Library General Public | 7 modify it under the terms of the GNU Library General Public |
365 void | 365 void |
366 expandargv (int *argcp, char ***argvp) | 366 expandargv (int *argcp, char ***argvp) |
367 { | 367 { |
368 /* The argument we are currently processing. */ | 368 /* The argument we are currently processing. */ |
369 int i = 0; | 369 int i = 0; |
370 /* Non-zero if ***argvp has been dynamically allocated. */ | 370 /* To check if ***argvp has been dynamically allocated. */ |
371 int argv_dynamic = 0; | 371 char ** const original_argv = *argvp; |
372 /* Limit the number of response files that we parse in order | 372 /* Limit the number of response files that we parse in order |
373 to prevent infinite recursion. */ | 373 to prevent infinite recursion. */ |
374 unsigned int iteration_limit = 2000; | 374 unsigned int iteration_limit = 2000; |
375 /* Loop over the arguments, handling response files. We always skip | 375 /* Loop over the arguments, handling response files. We always skip |
376 ARGVP[0], as that is the name of the program being run. */ | 376 ARGVP[0], as that is the name of the program being run. */ |
447 } | 447 } |
448 else | 448 else |
449 /* Parse the string. */ | 449 /* Parse the string. */ |
450 file_argv = buildargv (buffer); | 450 file_argv = buildargv (buffer); |
451 /* If *ARGVP is not already dynamically allocated, copy it. */ | 451 /* If *ARGVP is not already dynamically allocated, copy it. */ |
452 if (!argv_dynamic) | 452 if (*argvp == original_argv) |
453 *argvp = dupargv (*argvp); | 453 *argvp = dupargv (*argvp); |
454 /* Count the number of arguments. */ | 454 /* Count the number of arguments. */ |
455 file_argc = 0; | 455 file_argc = 0; |
456 while (file_argv[file_argc]) | 456 while (file_argv[file_argc]) |
457 ++file_argc; | 457 ++file_argc; |
458 /* Free the original option's memory. */ | |
459 free ((*argvp)[i]); | |
458 /* Now, insert FILE_ARGV into ARGV. The "+1" below handles the | 460 /* Now, insert FILE_ARGV into ARGV. The "+1" below handles the |
459 NULL terminator at the end of ARGV. */ | 461 NULL terminator at the end of ARGV. */ |
460 *argvp = ((char **) | 462 *argvp = ((char **) |
461 xrealloc (*argvp, | 463 xrealloc (*argvp, |
462 (*argcp + file_argc + 1) * sizeof (char *))); | 464 (*argcp + file_argc + 1) * sizeof (char *))); |