wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

join.c (418B)


      1 /* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
      2  * See LICENSE file for license details.
      3  */
      4 #include <fmt.h>
      5 #include "util.h"
      6 
      7 char*
      8 join(char **list, char *sep, Fmt *f) {
      9 	Fmt fmt;
     10 	char **p;
     11 
     12 	if(f == nil) {
     13 		f = &fmt;
     14 		if(fmtstrinit(f) < 0)
     15 			abort();
     16 	}
     17 
     18 	for(p=list; *p; p++) {
     19 		if(p != list)
     20 			fmtstrcpy(f, sep);
     21 		fmtstrcpy(f, *p);
     22 	}
     23 
     24 	if(f != &fmt)
     25 		return nil;
     26 	return fmtstrflush(f);
     27 }