diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2019-10-12 05:11:51 +0200 |
---|---|---|
committer | Andrew Gregory <andrew.gregory.8@gmail.com> | 2019-10-12 05:14:29 +0200 |
commit | a82b0028e431dbd8bb3512c3193b52985da82ec2 (patch) | |
tree | 7d8b96002c05ba3f5a621bf8efc74530b59b3a01 /src/pacman/pacman.c | |
parent | a2c4ad46751e4dcb85a739437d9331bf9282d9be (diff) | |
download | pacman-a82b0028e431dbd8bb3512c3193b52985da82ec2.tar.gz pacman-a82b0028e431dbd8bb3512c3193b52985da82ec2.tar.xz |
add arg_to_string helper
Converts an argc/argv pair to a string for presentation to the user.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Diffstat (limited to 'src/pacman/pacman.c')
-rw-r--r-- | src/pacman/pacman.c | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index b7406cea..c8e86b9d 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -1066,28 +1066,12 @@ static int parseargs(int argc, char *argv[]) */ static void cl_to_log(int argc, char *argv[]) { - size_t size = 0; - int i; - for(i = 0; i < argc; i++) { - size += strlen(argv[i]) + 1; + char *cl_text = arg_to_string(argc, argv); + if(cl_text) { + alpm_logaction(config->handle, PACMAN_CALLER_PREFIX, + "Running '%s'\n", cl_text); + free(cl_text); } - if(!size) { - return; - } - char *cl_text = malloc(size); - if(!cl_text) { - return; - } - char *p = cl_text; - for(i = 0; i + 1 < argc; i++) { - strcpy(p, argv[i]); - p += strlen(argv[i]); - *p++ = ' '; - } - strcpy(p, argv[i]); - alpm_logaction(config->handle, PACMAN_CALLER_PREFIX, - "Running '%s'\n", cl_text); - free(cl_text); } /** Main function. |