Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/pacman/util.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/util.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/util.c')
-rw-r--r--src/pacman/util.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 8f6290db..68cdb2e9 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1771,3 +1771,26 @@ int pm_vfprintf(FILE *stream, alpm_loglevel_t level, const char *format, va_list
ret = vfprintf(stream, format, args);
return ret;
}
+
+char *arg_to_string(int argc, char *argv[])
+{
+ char *cl_text, *p;
+ size_t size = 0;
+ int i;
+ for(i = 0; i < argc; i++) {
+ size += strlen(argv[i]) + 1;
+ }
+ if(!size) {
+ return NULL;
+ }
+ if(!(cl_text = malloc(size))) {
+ return NULL;
+ }
+ for(p = cl_text, i = 0; i + 1 < argc; i++) {
+ strcpy(p, argv[i]);
+ p += strlen(argv[i]);
+ *p++ = ' ';
+ }
+ strcpy(p, argv[i]);
+ return cl_text;
+}