/* generic interface for debug messages */
-#ifndef _LIB_DEBUG_H
-#define _LIB_DEBUG_H
+#ifndef MUTT_LIB_LIB_DEBUG_H
+#define MUTT_LIB_LIB_DEBUG_H
#include <stdio.h>
#endif /* !DEBUG */
-#endif /* !_LIB_DEBUG_H */
+#endif /* MUTT_LIB_LIB_DEBUG_H */
return -1;
}
+
+int rx_sanitize_string(char *dst, ssize_t n, const char *src)
+{
+ while (*src) {
+ if (n <= 1)
+ break;
+
+ /* these characters must be escaped in regular expressions */
+ if (strchr("^.[$()|*+?{\\", *src)) {
+ if (n <= 2)
+ break;
+
+ *dst++ = '\\';
+ n--;
+ }
+
+ *dst++ = *src++;
+ n--;
+ }
+
+ *dst = '\0';
+
+ return *src ? -1 : 0;
+}
* this is an internal abstraction layer for regular expressions
*/
-#ifndef _LIB_RX_H
-#define _LIB_RX_H
+#ifndef MUTT_LIB_LIB_RX_H
+#define MUTT_LIB_LIB_RX_H
#include <sys/types.h>
#include <regex.h>
/* 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 */
+int rx_sanitize_string(char *, ssize_t, const char *);
+
#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 */
+#endif /* !MUTT_LIB_LIB_RX_H */
}
-/* these characters must be escaped in regular expressions */
-
-static char rx_special_chars[] = "^.[$()|*+?{\\";
-
-int mutt_rx_sanitize_string (char *dest, size_t destlen, const char *src)
-{
- while (*src && --destlen > 2) {
- if (strchr (rx_special_chars, *src)) {
- *dest++ = '\\';
- destlen--;
- }
- *dest++ = *src++;
- }
-
- *dest = '\0';
-
- if (*src)
- return -1;
- else
- return 0;
-}
-
const char *
mutt_strsysexit(int e)
{
/* The actual library functions. */
-int mutt_rx_sanitize_string (char *, size_t, const char *);
-
void mutt_nocurses_error (const char *, ...);
const char *mutt_strsysexit(int e);
}
if (rx && *p && !recurse) {
- mutt_rx_sanitize_string (q, sizeof (q), p);
+ rx_sanitize_string (q, sizeof (q), p);
snprintf (tmp, sizeof (tmp), "%s%s", q, tail);
}
else