909{
910
911
912 struct PatternList *curlist = NULL;
913 bool pat_not = false;
914 bool all_addr = false;
915 bool pat_or = false;
916 bool implicit = true;
917 bool is_alias = false;
919 char *p = NULL;
920 char *buf = NULL;
922
923 if (!s || (s[0] == '\0'))
924 {
926 return NULL;
927 }
928
932
935 {
937 {
938 case '^':
940 all_addr = !all_addr;
941 break;
942 case '!':
944 pat_not = !pat_not;
945 break;
946 case '@':
948 is_alias = !is_alias;
949 break;
950 case '|':
951 if (!pat_or)
952 {
953 if (!curlist)
954 {
957 return NULL;
958 }
959
962 {
963
966 }
967
968 pat_or = true;
969 }
971 implicit = false;
975 break;
976 case '%':
977 case '=':
978 case '~':
979 {
980 if (ps->
dptr[1] ==
'\0')
981 {
983 goto cleanup;
984 }
985 short thread_op = 0;
986 if (ps->
dptr[1] ==
'(')
988 else if ((ps->
dptr[1] ==
'<') && (ps->
dptr[2] ==
'('))
990 else if ((ps->
dptr[1] ==
'>') && (ps->
dptr[2] ==
'('))
992 if (thread_op != 0)
993 {
999 {
1001 goto cleanup;
1002 }
1004 leaf->
op = thread_op;
1011
1015 {
1017 goto cleanup;
1018 }
1021 break;
1022 }
1023 if (implicit && pat_or)
1024 {
1025
1028 pat_or = false;
1029 }
1030
1032 if (!entry)
1033 {
1035 goto cleanup;
1036 }
1037 if (entry->
flags && ((flags & entry->
flags) == 0))
1038 {
1040 goto cleanup;
1041 }
1042
1050 leaf->
op = entry->
op;
1054
1059 {
1060 if (ps->
dptr[0] ==
'\0')
1061 {
1063 goto cleanup;
1064 }
1066 {
1069 goto cleanup;
1070 break;
1072 if (!
eat_date(leaf, flags, ps, err))
1073 goto cleanup;
1074 break;
1077 goto cleanup;
1078 break;
1081 goto cleanup;
1082 break;
1084 if (!
eat_query(leaf, flags, ps, err, m))
1085 goto cleanup;
1086 break;
1087 default:
1088 break;
1089 }
1090 }
1091 implicit = true;
1092 break;
1093 }
1094
1095 case '(':
1096 {
1099 {
1101 goto cleanup;
1102 }
1103
1107 if (!sub)
1108 goto cleanup;
1110 if (curlist)
1111 {
1114 }
1115 else
1116 {
1117 curlist = sub;
1118 }
1126 break;
1127 }
1128
1129 default:
1131 goto cleanup;
1132 }
1134 }
1136
1137 if (!curlist)
1138 {
1140 return NULL;
1141 }
1142
1144 {
1147 }
1148
1149 return curlist;
1150
1151cleanup:
1154 return NULL;
1155}
void buf_seek(struct Buffer *buf, size_t offset)
Set current read/write position to offset from beginning.
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
static struct Pattern * attach_new_leaf(struct PatternList **curlist)
Attach a new Pattern to a List.
static char * find_matching_paren(char *s)
Find the matching parenthesis.
struct PatternList * mutt_pattern_comp(struct MailboxView *mv, struct Menu *menu, const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
static bool eat_query(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err, struct Mailbox *m)
Parse a query for an external search program - Implements eat_arg_t -.
bool eat_message_range(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err, struct MailboxView *mv)
Parse a range of message numbers - Implements eat_arg_t -.
static bool eat_range(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err)
Parse a number range - Implements eat_arg_t -.
static bool eat_date(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err)
Parse a date pattern - Implements eat_arg_t -.
static bool eat_regex(struct Pattern *pat, PatternCompFlags flags, struct Buffer *s, struct Buffer *err)
Parse a regex - Implements eat_arg_t -.
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
const struct PatternFlags * lookup_tag(char tag)
Lookup a pattern modifier.
#define MUTT_PC_SEND_MODE_SEARCH
Allow send-mode body searching.
@ MUTT_PAT_OR
Either pattern can match.
@ MUTT_PAT_CHILDREN
Pattern matches a child email.
@ MUTT_PAT_PARENT
Pattern matches parent.
@ MUTT_PAT_AND
Both patterns must match.
@ MUTT_PAT_THREAD
Pattern matches email thread.
@ EAT_RANGE
Process a number (range)
@ EAT_MESSAGE_RANGE
Process a message number (range)
@ EAT_DATE
Process a date (range)
@ EAT_QUERY
Process a query string.
@ EAT_REGEX
Process a regex.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
String manipulation buffer.
char * dptr
Current read/write position.
struct Mailbox * mailbox
Current Mailbox.
Mapping between user character and internal constant.
enum PatternEat eat_arg
Type of function needed to parse flag, e.g. EAT_DATE.
PatternCompFlags flags
Pattern flags, e.g. MUTT_PC_FULL_MSG.
int op
Operation to perform, e.g. MUTT_PAT_SCORE.
bool all_addr
All Addresses in the list must match.
bool is_alias
Is there an alias for this Address?
short op
Operation, e.g. MUTT_PAT_SCORE.
bool sendmode
Evaluate searches in send-mode.
bool pat_not
Pattern should be inverted (not)