comm.c (748B)
1 /* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail> 2 * See LICENSE file for license details. 3 */ 4 #include <string.h> 5 #include "util.h" 6 #include <stuff/x11.h> 7 8 9 char** 10 comm(int cols, char **toka, char **tokb) { 11 Vector_ptr vec; 12 char **ret; 13 int cmp; 14 15 vector_pinit(&vec); 16 while(*toka || *tokb) { 17 if(!*toka) 18 cmp = 1; 19 else if(!*tokb) 20 cmp = -1; 21 else 22 cmp = strcmp(*toka, *tokb); 23 if(cmp < 0) { 24 if(cols & CLeft) 25 vector_ppush(&vec, *toka); 26 toka++; 27 }else if(cmp > 0) { 28 if(cols & CRight) 29 vector_ppush(&vec, *tokb); 30 tokb++; 31 }else { 32 if(cols & CCenter) 33 vector_ppush(&vec, *toka); 34 toka++; 35 tokb++; 36 } 37 } 38 vector_ppush(&vec, nil); 39 ret = strlistdup((char**)vec.ary); 40 free(vec.ary); 41 return ret; 42 }