Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
713303a2
提交
713303a2
authored
12月 18, 2013
作者:
Eliot Gable
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add case-insensitive search to switch_regex_match() based on code from switch_regex_perform().
上级
635fbc4b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
37 行增加
和
5 行删除
+37
-5
switch_regex.c
src/switch_regex.c
+37
-5
没有找到文件。
src/switch_regex.c
浏览文件 @
713303a2
...
@@ -79,6 +79,9 @@ SWITCH_DECLARE(int) switch_regex_perform(const char *field, const char *expressi
...
@@ -79,6 +79,9 @@ SWITCH_DECLARE(int) switch_regex_perform(const char *field, const char *expressi
if
((
opts
=
strrchr
(
tmp
,
'/'
)))
{
if
((
opts
=
strrchr
(
tmp
,
'/'
)))
{
*
opts
++
=
'\0'
;
*
opts
++
=
'\0'
;
}
else
{
}
else
{
/* Note our error */
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Regular Expression Error expression[%s] missing ending '/' delimeter
\n
"
,
expression
);
goto
end
;
goto
end
;
}
}
expression
=
tmp
;
expression
=
tmp
;
...
@@ -212,9 +215,35 @@ SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, c
...
@@ -212,9 +215,35 @@ SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, c
int
match_count
=
0
;
/* Number of times the regex was matched */
int
match_count
=
0
;
/* Number of times the regex was matched */
int
offset_vectors
[
255
];
/* not used, but has to exist or pcre won't even try to find a match */
int
offset_vectors
[
255
];
/* not used, but has to exist or pcre won't even try to find a match */
int
pcre_flags
=
0
;
int
pcre_flags
=
0
;
uint32_t
flags
=
0
;
char
*
tmp
=
NULL
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
if
(
*
expression
==
'/'
)
{
char
*
opts
=
NULL
;
tmp
=
strdup
(
expression
+
1
);
assert
(
tmp
);
if
((
opts
=
strrchr
(
tmp
,
'/'
)))
{
*
opts
++
=
'\0'
;
}
else
{
/* Note our error */
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Regular Expression Error expression[%s] missing ending '/' delimeter
\n
"
,
expression
);
goto
end
;
}
expression
=
tmp
;
if
(
opts
)
{
if
(
strchr
(
opts
,
'i'
))
{
flags
|=
PCRE_CASELESS
;
}
if
(
strchr
(
opts
,
's'
))
{
flags
|=
PCRE_DOTALL
;
}
}
}
/* Compile the expression */
/* Compile the expression */
pcre_prepared
=
pcre_compile
(
expression
,
0
,
&
error
,
&
error_offset
,
NULL
);
pcre_prepared
=
pcre_compile
(
expression
,
flags
,
&
error
,
&
error_offset
,
NULL
);
/* See if there was an error in the expression */
/* See if there was an error in the expression */
if
(
error
!=
NULL
)
{
if
(
error
!=
NULL
)
{
...
@@ -228,7 +257,7 @@ SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, c
...
@@ -228,7 +257,7 @@ SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, c
"Regular Expression Error expression[%s] error[%s] location[%d]
\n
"
,
expression
,
error
,
error_offset
);
"Regular Expression Error expression[%s] error[%s] location[%d]
\n
"
,
expression
,
error
,
error_offset
);
/* We definitely didn't match anything */
/* We definitely didn't match anything */
return
SWITCH_STATUS_FALSE
;
goto
end
;
}
}
if
(
*
partial
)
{
if
(
*
partial
)
{
...
@@ -250,14 +279,17 @@ SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, c
...
@@ -250,14 +279,17 @@ SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, c
/* Was it a match made in heaven? */
/* Was it a match made in heaven? */
if
(
match_count
>
0
)
{
if
(
match_count
>
0
)
{
*
partial
=
0
;
*
partial
=
0
;
return
SWITCH_STATUS_SUCCESS
;
switch_goto_status
(
SWITCH_STATUS_SUCCESS
,
end
)
;
}
else
if
(
match_count
==
PCRE_ERROR_PARTIAL
||
match_count
==
PCRE_ERROR_BADPARTIAL
)
{
}
else
if
(
match_count
==
PCRE_ERROR_PARTIAL
||
match_count
==
PCRE_ERROR_BADPARTIAL
)
{
/* yes it is already set, but the code is clearer this way */
/* yes it is already set, but the code is clearer this way */
*
partial
=
1
;
*
partial
=
1
;
return
SWITCH_STATUS_SUCCESS
;
switch_goto_status
(
SWITCH_STATUS_SUCCESS
,
end
)
;
}
else
{
}
else
{
return
SWITCH_STATUS_FALSE
;
goto
end
;
}
}
end
:
switch_safe_free
(
tmp
);
return
status
;
}
}
SWITCH_DECLARE
(
switch_status_t
)
switch_regex_match
(
const
char
*
target
,
const
char
*
expression
)
SWITCH_DECLARE
(
switch_status_t
)
switch_regex_match
(
const
char
*
target
,
const
char
*
expression
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论