wmii

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

grep.c (380B)


      1 /* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
      2  * See LICENSE file for license details.
      3  */
      4 #include "util.h"
      5 
      6 
      7 void
      8 grep(char **list, Reprog *re, int flags) {
      9 	char **p, **q;
     10 	int res;
     11 
     12 	q = list;
     13 	for(p=q; *p; p++) {
     14 		res = 0;
     15 		if(re)
     16 			res = regexec(re, *p, nil, 0);
     17 		if(res && !(flags & GInvert)
     18 		|| !res && (flags & GInvert))
     19 			*q++ = *p;
     20 	}
     21 	*q = nil;
     22 }