mirror of
https://github.com/weechat/weechat.git
synced 2026-07-08 02:33:12 +02:00
core: add wildcard matching operators to eval (closes #608)
This commit is contained in:
committed by
Sébastien Helleu
parent
a9f6c34fae
commit
1329dfb57a
@@ -7254,6 +7254,8 @@ command_init ()
|
||||
" > greater\n"
|
||||
" =~ is matching POSIX extended regex\n"
|
||||
" !~ is NOT matching POSIX extended regex\n"
|
||||
" =* is matching wildcard mask\n"
|
||||
" !* is NOT matching wildcard mask\n"
|
||||
"\n"
|
||||
"An expression is considered as \"true\" if it is not NULL, not "
|
||||
"empty, and different from \"0\".\n"
|
||||
@@ -7326,7 +7328,8 @@ command_init ()
|
||||
" /eval -n -c abcd =~ ^ABC ==> 1\n"
|
||||
" /eval -n -c abcd =~ (?-i)^ABC ==> 0\n"
|
||||
" /eval -n -c abcd =~ (?-i)^abc ==> 1\n"
|
||||
" /eval -n -c abcd !~ abc ==> 0"),
|
||||
" /eval -n -c abcd !~ abc ==> 0\n"
|
||||
" /eval -n -c abcd =* a*d ==> 1"),
|
||||
"-n|-s|-c -n|-s|-c",
|
||||
&command_eval, NULL, NULL);
|
||||
hook_command (
|
||||
|
||||
+9
-1
@@ -47,7 +47,7 @@ char *logical_ops[EVAL_NUM_LOGICAL_OPS] =
|
||||
{ "||", "&&" };
|
||||
|
||||
char *comparisons[EVAL_NUM_COMPARISONS] =
|
||||
{ "=~", "!~", "==", "!=", "<=", "<", ">=", ">" };
|
||||
{ "=~", "!~", "=*", "!*", "==", "!=", "<=", "<", ">=", ">" };
|
||||
|
||||
|
||||
char *eval_replace_vars (const char *expr, struct t_hashtable *pointers,
|
||||
@@ -791,6 +791,14 @@ eval_compare (const char *expr1, int comparison, const char *expr2)
|
||||
rc ^= 1;
|
||||
goto end;
|
||||
}
|
||||
else if ((comparison == EVAL_COMPARE_STRING_MATCHING)
|
||||
|| (comparison == EVAL_COMPARE_STRING_NOT_MATCHING))
|
||||
{
|
||||
rc = string_match (expr1, expr2, 0);
|
||||
if (comparison == EVAL_COMPARE_STRING_NOT_MATCHING)
|
||||
rc ^= 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
length1 = strlen (expr1);
|
||||
length2 = strlen (expr2);
|
||||
|
||||
@@ -42,6 +42,8 @@ enum t_eval_comparison
|
||||
{
|
||||
EVAL_COMPARE_REGEX_MATCHING = 0,
|
||||
EVAL_COMPARE_REGEX_NOT_MATCHING,
|
||||
EVAL_COMPARE_STRING_MATCHING,
|
||||
EVAL_COMPARE_STRING_NOT_MATCHING,
|
||||
EVAL_COMPARE_EQUAL,
|
||||
EVAL_COMPARE_NOT_EQUAL,
|
||||
EVAL_COMPARE_LESS_EQUAL,
|
||||
|
||||
Reference in New Issue
Block a user