commit 7a742c5ddc352f61634482168cef301dab05530d
parent 69919855802099ad2545aa21c4cfa9683a9d2dc8
Author: Christoph Lohmann <20h@r-36.net>
Date: Tue, 24 Jul 2012 11:54:04 +0200
Add llist_cifind and make it default for rpview -e.
Diffstat:
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/llist.c b/llist.c
@@ -290,7 +290,8 @@ llist_pop(llist_t *llist)
enum {
FIND_NORMAL = 0x0,
- FIND_EXTENDED = 0x1
+ FIND_EXTENDED = 0x1,
+ FIND_CI = 0x2
};
llist_t *
@@ -300,8 +301,10 @@ llist_internfind(llist_t *llist, char *regex, int mode)
llistelem_t *elem;
regex_t preg;
- if (regcomp(&preg, regex, REG_EXTENDED|REG_NOSUB))
+ if (regcomp(&preg, regex, REG_EXTENDED|REG_NOSUB \
+ |((mode & FIND_CI)? REG_ICASE : 0))) {
return NULL;
+ }
results = llist_new();
forllist(llist, elem) {
@@ -344,6 +347,18 @@ llist_efind(llist_t *llist, char *regex)
return llist_internfind(llist, regex, FIND_EXTENDED);
}
+llist_t *
+llist_cifind(llist_t *llist, char *regex)
+{
+ return llist_internfind(llist, regex, FIND_NORMAL|FIND_CI);
+}
+
+llist_t *
+llist_ecifind(llist_t *llist, char *regex)
+{
+ return llist_internfind(llist, regex, FIND_EXTENDED|FIND_CI);
+}
+
enum {
GET_NORMAL = 0x01,
GET_EXTENDED = 0x02,
diff --git a/llist.h b/llist.h
@@ -65,6 +65,8 @@ llistelem_t *llist_pop(llist_t *llist);
llist_t *llist_find(llist_t *llist, char *regex);
llist_t *llist_efind(llist_t *llist, char *regex);
+llist_t *llist_cifind(llist_t *llist, char *regex);
+llist_t *llist_ecifind(llist_t *llist, char *regex);
llistelem_t *llist_get(llist_t *llist, char *key);
llistelem_t *llist_ciget(llist_t *llist, char *key);
llistelem_t *llist_eget(llist_t *llist, char *key);
diff --git a/view.c b/view.c
@@ -154,7 +154,7 @@ view_printpart(char *id, mime_t *mime, llist_t *dhdrs, llist_t *partl,
}
} else {
forllist(dhdrs, delem) {
- hlist = llist_find(mime->hdrs, delem->key);
+ hlist = llist_cifind(mime->hdrs, delem->key);
if (hlist != NULL) {
forllist(hlist, helem) {
hvalue = mime_decodeheader(