Commit c9a09b91 by Etienne Samson

examples: extract argument conversion helper

parent 204a464f
......@@ -181,3 +181,17 @@ int match_arg_separator(struct args_info *args)
args->pos++;
return 1;
}
void strarray_from_args(git_strarray *array, struct args_info *args)
{
size_t i;
array->count = args->argc - args->pos;
array->strings = calloc(array->count, sizeof(char *));
assert(array->strings != NULL);
for (i = 0; args->pos < args->argc; ++args->pos) {
array->strings[i++] = args->argv[args->pos];
}
args->pos = args->argc;
}
......@@ -82,4 +82,9 @@ extern int match_bool_arg(int *out, struct args_info *args, const char *opt);
*/
extern int match_arg_separator(struct args_info *args);
/**
* Consume all remaining arguments in a git_strarray
*/
extern void strarray_from_args(git_strarray *array, struct args_info *args);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment