-static void
-update_argv (const char *filename, struct argp_state *state)
-{
- FILE *fp;
- size_t count = 0, i;
- char *start, *p;
- char **new_argv;
- size_t new_argc;
- bool is_stdin = false;
- enum read_file_list_state read_state;
- int term = filename_terminator;
-
- if (!strcmp (filename, "-"))
- {
- is_stdin = true;
- request_stdin ("-T");
- fp = stdin;
- }
- else
- {
- add_file_id (filename);
- if ((fp = fopen (filename, "r")) == NULL)
- open_fatal (filename);
- }
-
- while ((read_state = read_name_from_file (fp, &argv_stk, term))
- != file_list_end)
- {
- switch (read_state)
- {
- case file_list_success:
- count++;
- break;
-
- case file_list_end: /* won't happen, just to pacify gcc */
- break;
-
- case file_list_zero:
- {
- size_t size;
-
- WARNOPT (WARN_FILENAME_WITH_NULS,
- (0, 0, N_("%s: file name read contains nul character"),
- quotearg_colon (filename)));
-
- /* Prepare new stack contents */
- size = obstack_object_size (&argv_stk);
- p = obstack_finish (&argv_stk);
- for (; size > 0; size--, p++)
- if (*p)
- obstack_1grow (&argv_stk, *p);
- else
- obstack_1grow (&argv_stk, '\n');
- obstack_1grow (&argv_stk, 0);
- count = 1;
- /* Read rest of files using new filename terminator */
- term = 0;
- break;
- }
-
- case file_list_skip:
- break;
- }
- }
-
- if (!is_stdin)
- fclose (fp);
-
- if (count == 0)
- return;
-
- start = obstack_finish (&argv_stk);
-
- if (term == 0)
- for (p = start; *p; p += strlen (p) + 1)
- if (p[0] == '-')
- count++;
-
- new_argc = state->argc + count;
- new_argv = xmalloc (sizeof (state->argv[0]) * (new_argc + 1));
- memcpy (new_argv, state->argv, sizeof (state->argv[0]) * (state->argc + 1));
- state->argv = new_argv;
- memmove (&state->argv[state->next + count], &state->argv[state->next],
- (state->argc - state->next + 1) * sizeof (state->argv[0]));
-
- state->argc = new_argc;
-
- for (i = state->next, p = start; *p; p += strlen (p) + 1, i++)
- {
- if (term == 0 && p[0] == '-')
- state->argv[i++] = (char *) "--add-file";
- state->argv[i] = p;
- }
-}
-