those list2_t are really tasteless.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
#include <lib-lib/macros.h>
#include <lib-lib/mapping.h>
#include <lib-lib/debug.h>
+#include <lib-lib/rx.h>
#include <lib-ui/curses.h>
#include <lib-ui/enter.h>
#include <lib-ui/menu.h>
-#include "lib/rx.h"
-
#include "mutt.h"
#include "mutt_idna.h"
#include "sort.h"
#include <lib-lib/str.h>
#include <lib-lib/date.h>
+#include <lib-lib/rx.h>
#include "lib/list.h"
-#include "lib/rx.h"
WHERE void (*mutt_error) (const char *, ...);
WHERE void (*mutt_message) (const char *, ...);
# include "config.h"
#endif
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+
+#include <lib-lib/rx.h>
+#include <lib-lib/str.h>
+
+#include <lib-mime/mime.h>
+
#include <lib-ui/curses.h>
#include "mutt.h"
#include <lib-crypt/crypt.h>
#include "mutt_idna.h"
-#include <lib-lib/str.h>
-
-#include <lib-mime/mime.h>
-
-#include "lib/rx.h"
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <locale.h>
-
int mutt_is_mail_list (address_t * addr)
{
if (!rx_list_match (UnMailLists, addr->mailbox))
# include "config.h"
#endif
+#include <limits.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <unistd.h>
+
#include <lib-lib/mem.h>
#include <lib-lib/str.h>
#include <lib-lib/macros.h>
#include <lib-lib/buffer.h>
#include <lib-lib/file.h>
+#include <lib-lib/rx.h>
#include "mutt.h"
#include "mx.h"
#include <lib-crypt/crypt.h>
#include "compress.h"
-#include "lib/rx.h"
-
-#include <limits.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <unistd.h>
-
#define ERROR_STOP 0
typedef struct hook {
#include <lib-lib/buffer.h>
#include <lib-lib/mapping.h>
#include <lib-lib/debug.h>
+#include <lib-lib/rx.h>
#include <lib-ui/curses.h>
#include "mx.h"
#include "init.h"
-#include "lib/rx.h"
#include "lib/list.h"
#include <ctype.h>
i = rx_lookup ((*list), rx->pattern);
if (i >= 0)
- rx_free (&rx);
+ rx_delete(&rx);
else
list_push_back (list, rx);
return 0;
return 0;
if (spam->rx && !m_strcmp(spam->rx->pattern, pat)) {
*list = spam->next;
- rx_free (&spam->rx);
+ rx_delete(&spam->rx);
p_delete(&spam->template);
p_delete(&spam);
return 1;
for (spam = prev->next; spam;) {
if (!m_strcmp(spam->rx->pattern, pat)) {
prev->next = spam->next;
- rx_free (&spam->rx);
+ rx_delete(&spam->rx);
p_delete(&spam->template);
p_delete(&spam);
spam = prev->next;
int i = 0;
if (m_strcmp("*", str) == 0) {
- list_del (l, (list_del_t*) rx_free);
+ list_del (l, (list_del_t*) rx_delete);
return (0);
}
else {
i = rx_lookup ((*l), str);
if (i >= 0) {
rx_t* r = list_pop_idx ((*l), i);
- rx_free (&r);
+ rx_delete(&r);
return (0);
}
}
/* "*" is a special case. */
if (!m_strcmp(buf->data, "*")) {
mutt_free_spam_list (&SpamList);
- list_del (&NoSpamList, (list_del_t*) rx_free);
+ list_del (&NoSpamList, (list_del_t*) rx_delete);
return 0;
}
liblib_a_SOURCES = mem.h str.h ascii.h buffer.h hash.h list.h file.h mapping.h \
str.c ascii.c buffer.c hash.c list.c file.c mapping.c \
\
- date.h debug.h \
- date.c debug.c
+ date.h debug.h rx.h \
+ date.c debug.c rx.c
noinst_HEADERS = mem.h str.h ascii.h buffer.h hash.h list.h file.h mapping.h \
- date.c
+ date.h debug.h rx.h
-include ../cflags.mk
--- /dev/null
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Copyright © 2006 Pierre Habouzit
+ */
+/*
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <lib-lib/mem.h>
+#include <lib-lib/str.h>
+#include <lib-lib/rx.h>
+
+rx_t *rx_compile(const char *s, int flags)
+{
+ rx_t *pp = p_new(rx_t, 1);
+
+ pp->pattern = m_strdup(s);
+ pp->rx = p_new(regex_t, 1);
+
+ if (REGCOMP(pp->rx, NONULL(s), flags) != 0) {
+ rx_delete(&pp);
+ }
+
+ return pp;
+}
+
+void rx_delete(rx_t **p)
+{
+ p_delete(&(*p)->pattern);
+ regfree((*p)->rx);
+ p_delete(&(*p)->rx);
+ p_delete(p);
+}
+
+int rx_list_match(list2_t *l, const char *pat)
+{
+ int i;
+
+ if (!pat || !*pat || list_empty(l))
+ return 0;
+
+ for (i = 0; i < l->length; i++) {
+ if (!REGEXEC(((rx_t*)l->data[i])->rx, pat))
+ return 1;
+ }
+
+ return 0;
+}
+
+int rx_lookup (list2_t *l, const char *pat)
+{
+ int i;
+
+ if (!pat || !*pat || list_empty(l))
+ return -1;
+
+ for (i = 0; i < l->length; i++) {
+ if (!strcmp(((rx_t*)l->data[i])->pattern, pat))
+ return i;
+ }
+
+ return -1;
+}
--- /dev/null
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * Copyright © 2006 Pierre Habouzit
+ */
+/*
+ * This file is part of mutt-ng, see http://www.muttng.org/.
+ * It's licensed under the GNU General Public License,
+ * please see the file GPL in the top level source directory.
+ */
+
+/*
+ * this is an internal abstraction layer for regular expressions
+ */
+
+#ifndef _LIB_RX_H
+#define _LIB_RX_H
+
+#include <sys/types.h>
+#include <regex.h>
+
+#include "../lib/list.h"
+
+/* this is a non-standard option supported by Solaris 2.5.x which allows
+ * patterns of the form \<...\>
+ */
+#ifndef REG_WORDS
+#define REG_WORDS 0
+#endif
+
+typedef struct rx_t {
+ char *pattern; /* printable version */
+ regex_t *rx; /* compiled expression */
+ int not; /* do not match */
+} rx_t;
+
+rx_t* rx_compile (const char*, int);
+void rx_delete(rx_t **);
+
+/* for handling lists */
+int rx_list_match(list2_t*, const char*); /* match all items list agains string */
+int rx_lookup(list2_t*, const char*); /* lookup pattern */
+
+#define REGCOMP(X,Y,Z) regcomp(X, Y, REG_WORDS|REG_EXTENDED|(Z))
+#define REGEXEC(X,Y) regexec(X, Y, 0, NULL, 0)
+
+#endif /* !_LIB_RX_H */
#include <lib-lib/str.h>
#include <lib-lib/macros.h>
#include <lib-lib/file.h>
+#include <lib-lib/rx.h>
#include <lib-ui/curses.h>
#include <lib-ui/menu.h>
#include "mutt_socket.h"
#include "mutt_ssl.h"
-#include "lib/rx.h"
-
typedef struct _tlssockdata {
gnutls_session state;
gnutls_certificate_credentials xcred;
* This file is named mutt_menu.h so it doesn't collide with ncurses menu.h
*/
-#include "keymap.h"
+#include <lib-lib/rx.h>
-#include "lib/rx.h"
+#include "keymap.h"
#define REDRAW_INDEX (1)
#define REDRAW_MOTION (1<<1)
AUTOMAKE_OPTIONS = foreign
noinst_LIBRARIES = libsane.a
-noinst_HEADERS = list.h rx.h
+noinst_HEADERS = list.h
-libsane_a_SOURCES = list.c rx.h list.h rx.c
+libsane_a_SOURCES = list.c list.h
-include ../cflags.mk
}
void list_del (list2_t** l, list_del_t* del) {
- size_t i = 0;
+ ssize_t i = 0;
if (!l || !*l)
return;
if (del)
return ret;
}
-list2_t* list_dup (list2_t* l, void* (*dup) (void*)) {
+list2_t* list_dup (list2_t* l, void* (*dup_f) (void*)) {
list2_t* ret = NULL;
int i = 0;
- if (list_empty(l) || !*dup)
+ if (list_empty(l) || !*dup_f)
return (NULL);
ret = list_new ();
ret->length = l->length;
ret->data = p_new(void*, l->length);
for (i = 0; i < l->length; i++)
- ret->data[i] = dup (l->data[i]);
+ ret->data[i] = dup_f (l->data[i]);
return (ret);
}
typedef struct list2_t {
void** data;
- size_t length;
+ ssize_t length;
} list2_t;
/*
+++ /dev/null
-/*
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <lib-lib/mem.h>
-#include <lib-lib/str.h>
-
-#include "rx.h"
-
-
-rx_t *rx_compile (const char *s, int flags) {
- rx_t *pp = p_new(rx_t, 1);
-
- pp->pattern = m_strdup(s);
- pp->rx = p_new(regex_t, 1);
- if (REGCOMP(pp->rx, NONULL (s), flags) != 0)
- rx_free (&pp);
-
- return pp;
-}
-
-void rx_free (rx_t** p) {
- p_delete(&(*p)->pattern);
- regfree ((*p)->rx);
- p_delete(&(*p)->rx);
- p_delete(p);
-}
-
-int rx_compare (const rx_t* r1, const rx_t* r2) {
- return (m_strcmp(r1->pattern, r2->pattern));
-}
-
-int rx_list_match (list2_t* l, const char* pat) {
- int i = 0;
- if (!pat || !*pat || list_empty(l))
- return (0);
- for (i = 0; i < l->length; i++)
- if (REGEXEC(((rx_t*) l->data[i])->rx, pat) == 0)
- return (1);
- return (0);
-}
-
-int rx_lookup (list2_t* l, const char* pat) {
- int i = 0;
- if (!pat || !*pat || list_empty(l))
- return (-1);
- for (i = 0; i < l->length; i++)
- if (m_strcmp(((rx_t*) l->data[i])->pattern, pat) == 0)
- return (i);
- return (-1);
-}
+++ /dev/null
-/*
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-
-/*
- * this is an internal abstraction layer for regular expressions
- */
-
-#ifndef _LIB_RX_H
-#define _LIB_RX_H
-
-#include <sys/types.h>
-#ifdef USE_GNU_REGEX
-#include "_regex.h"
-#else
-#include <regex.h>
-#endif
-
-#include "list.h"
-
-/* this is a non-standard option supported by Solaris 2.5.x which allows
- * patterns of the form \<...\>
- */
-#ifndef REG_WORDS
-#define REG_WORDS 0
-#endif
-
-typedef struct rx_t {
- char *pattern; /* printable version */
- regex_t *rx; /* compiled expression */
- int not; /* do not match */
-} rx_t;
-
-void rx_free (rx_t**);
-rx_t* rx_compile (const char*, int);
-
-/* for handling lists */
-int rx_compare (const rx_t*, const rx_t*); /* compare two patterns */
-int rx_list_match (list2_t*, const char*); /* match all items list agains string */
-int rx_lookup (list2_t*, const char*); /* lookup pattern */
-
-#define REGCOMP(X,Y,Z) regcomp(X, Y, REG_WORDS|REG_EXTENDED|(Z))
-#define REGEXEC(X,Y) regexec(X, Y, (size_t)0, (regmatch_t *)0, (int)0)
-
-#endif /* !_LIB_RX_H */
"+HAVE_REGCOMP "
#else
"-HAVE_REGCOMP "
-#endif
-#ifdef USE_GNU_REGEX
- "+USE_GNU_REGEX "
-#else
- "-USE_GNU_REGEX "
#endif
"\n "
#ifdef HAVE_COLOR
#include <lib-lib/buffer.h>
#include <lib-lib/hash.h>
#include <lib-lib/list.h>
+#include <lib-lib/rx.h>
#include <lib-mime/mime.h>
#include "charset.h"
-#include "lib/rx.h"
#ifndef HAVE_WC_FUNCS
# ifdef MB_LEN_MAX
while (*list) {
p = *list;
*list = (*list)->next;
- rx_free (&p->rx);
+ rx_delete(&p->rx);
p_delete(&p->template);
p_delete(&p);
}
#include <lib-lib/macros.h>
#include <lib-lib/mapping.h>
#include <lib-lib/debug.h>
+#include <lib-lib/rx.h>
#include <lib-ui/curses.h>
#include <lib-ui/enter.h>
#include <lib-crypt/crypt.h>
-#include "lib/rx.h"
#define ISHEADER(x) ((x) == MT_COLOR_HEADER || (x) == MT_COLOR_HDEFAULT)
# include "config.h"
#endif
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/file.h>
+#include <fcntl.h>
+
#include <lib-lib/mem.h>
#include <lib-lib/ascii.h>
#include <lib-lib/str.h>
#include <lib-lib/macros.h>
#include <lib-lib/file.h>
#include <lib-lib/mapping.h>
+#include <lib-lib/rx.h>
#include <lib-ui/curses.h>
#include <lib-ui/menu.h>
#include "remailer.h"
-#include "lib/rx.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <sys/types.h>
-#include <sys/file.h>
-#include <fcntl.h>
-
#define SW (option(OPTMBOXPANE)?SidebarWidth:0)
#ifdef MIXMASTER