summaryrefslogtreecommitdiffstats
path: root/src/pacman/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman/util.c')
-rw-r--r--src/pacman/util.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c
index a8ad0059..ef6c0f82 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -155,6 +155,32 @@ void indentprint(char *str, int indent)
}
}
+/* Condense a list of strings into one long (space-delimited) string
+ */
+char *buildstring(list_t *strlist)
+{
+ char *str;
+ int size = 1;
+ list_t *lp;
+
+ for(lp = strlist; lp; lp = lp->next) {
+ size += strlen(lp->data) + 1;
+ }
+ str = (char *)malloc(size);
+ if(str == NULL) {
+ ERR(NL, "failed to allocated %d bytes\n", size);
+ }
+ str[0] = '\0';
+ for(lp = strlist; lp; lp = lp->next) {
+ strcat(str, lp->data);
+ strcat(str, " ");
+ }
+ /* shave off the last space */
+ str[strlen(str)-1] = '\0';
+
+ return(str);
+}
+
/* Convert a string to uppercase
*/
char *strtoupper(char *str)