char *file = files[i];
switch (file[0]) {
case '+' : ptr->type = stINCLUDE; ++file; break;
+ case '~' : ptr->type = stSKIP; ++file; break;
case '-' : ++file; /*@fallthrough@*/
default : ptr->type = stEXCLUDE; break;
}
#include "matchlist.h"
#include <string.h>
-bool
+MatchType
MatchList_compare(struct MatchList const *list, char const *path)
{
- bool res = true;
struct MatchItem const * ptr = list->data;
struct MatchItem const * const end_ptr = list->data + list->count;
//write(1, "\n", 1);
for (; ptr<end_ptr; ++ptr) {
if ((ptr->cmp==0 && strcmp(ptr->name, path)==0) ||
- (ptr->cmp!=0 && (ptr->cmp)(ptr->name, path)==0)) {
- switch (ptr->type) {
- case stINCLUDE : res = true; break;
- case stEXCLUDE : res = false; break;
- default : abort();
- }
- break;
- }
+ (ptr->cmp!=0 && (ptr->cmp)(ptr->name, path)==0))
+ return ptr->type;
}
- return res;
+ return stINCLUDE;
}
#include <stdbool.h>
typedef int (*MatchItemCompareFunc)(char const *, char const *);
+typedef enum { stINCLUDE,stEXCLUDE,stSKIP } MatchType;
struct MatchItem
{
- enum { stINCLUDE, stEXCLUDE } type;
- char const * name;
- MatchItemCompareFunc cmp;
+ MatchType type;
+ char const * name;
+ MatchItemCompareFunc cmp;
};
struct MatchList
char **files, size_t count,
bool auto_type) NONNULL((1,3));
-bool MatchList_compare(struct MatchList const *,
+MatchType MatchList_compare(struct MatchList const *,
char const *path) NONNULL((1,2));
struct MatchItem
const * MatchList_find(struct MatchList const *,