Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/pacman/pacman.c
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2019-10-11 20:11:51 -0700
committerAndrew Gregory <andrew.gregory.8@gmail.com>2019-10-11 20:14:29 -0700
commita82b0028e431dbd8bb3512c3193b52985da82ec2 (patch)
tree7d8b96002c05ba3f5a621bf8efc74530b59b3a01 /src/pacman/pacman.c
parenta2c4ad46751e4dcb85a739437d9331bf9282d9be (diff)
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.c26
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.