Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
84d0515e
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
1 年多 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
84d0515e
编写于
9月 29, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
!555 musl支持iccarm版本的regexec同步至OpenHarmony-3.2-Beta3分支
Merge pull request !555 from wish/cherry-pick-1664347504
上级
80072adc
c4615c1b
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
4394 addition
and
0 deletion
+4394
-0
porting/liteos_m_iccarm/kernel/iccarm.gni
porting/liteos_m_iccarm/kernel/iccarm.gni
+3
-0
porting/liteos_m_iccarm/kernel/include/limits.h
porting/liteos_m_iccarm/kernel/include/limits.h
+2
-0
porting/liteos_m_iccarm/kernel/src/include/features.h
porting/liteos_m_iccarm/kernel/src/include/features.h
+16
-0
porting/liteos_m_iccarm/kernel/src/regex/regcomp.c
porting/liteos_m_iccarm/kernel/src/regex/regcomp.c
+2954
-0
porting/liteos_m_iccarm/kernel/src/regex/regexec.c
porting/liteos_m_iccarm/kernel/src/regex/regexec.c
+1028
-0
porting/liteos_m_iccarm/kernel/src/regex/tre-mem.c
porting/liteos_m_iccarm/kernel/src/regex/tre-mem.c
+158
-0
porting/liteos_m_iccarm/kernel/src/regex/tre.h
porting/liteos_m_iccarm/kernel/src/regex/tre.h
+233
-0
未找到文件。
porting/liteos_m_iccarm/kernel/iccarm.gni
浏览文件 @
84d0515e
...
...
@@ -38,4 +38,7 @@ ICCARM_ADAPT_SRC_COMMON = [
"$MUSLPORTINGDIR/src/network/htons.c",
"$MUSLPORTINGDIR/src/network/ntohl.c",
"$MUSLPORTINGDIR/src/network/ntohs.c",
"$MUSLPORTINGDIR/src/regex/regcomp.c",
"$MUSLPORTINGDIR/src/regex/regexec.c",
"$MUSLPORTINGDIR/src/regex/tre-mem.c",
]
porting/liteos_m_iccarm/kernel/include/limits.h
浏览文件 @
84d0515e
...
...
@@ -40,6 +40,8 @@
#define IOV_MAX 1024
#define SSIZE_MAX LONG_MAX
#define PTHREAD_KEYS_MAX 128
#define CHARCLASS_NAME_MAX 14
#define RE_DUP_MAX 255
#include_next <limits.h>
#endif
/* _ADAPT_LIMITS_H */
porting/liteos_m_iccarm/kernel/src/include/features.h
0 → 100644
浏览文件 @
84d0515e
#ifndef FEATURES_H
#define FEATURES_H
#include "../../include/features.h"
#define weak __attribute__((weak))
#define hidden
#ifndef weak_alias
#define weak_alias(old, new) \
extern __typeof(old) new __attribute__((weak, alias(#old)))
#endif
#ifndef strong_alias
#define strong_alias(old, new) \
extern __typeof(old) new __attribute__((alias(#old)))
#endif
#endif
porting/liteos_m_iccarm/kernel/src/regex/regcomp.c
0 → 100644
浏览文件 @
84d0515e
此差异已折叠。
点击以展开。
porting/liteos_m_iccarm/kernel/src/regex/regexec.c
0 → 100644
浏览文件 @
84d0515e
此差异已折叠。
点击以展开。
porting/liteos_m_iccarm/kernel/src/regex/tre-mem.c
0 → 100644
浏览文件 @
84d0515e
/*
tre-mem.c - TRE memory allocator
Copyright (c) 2001-2009 Ville Laurikari <vl@iki.fi>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
This memory allocator is for allocating small memory blocks efficiently
in terms of memory overhead and execution speed. The allocated blocks
cannot be freed individually, only all at once. There can be multiple
allocators, though.
*/
#include <stdlib.h>
#include <string.h>
#include "tre.h"
/*
This memory allocator is for allocating small memory blocks efficiently
in terms of memory overhead and execution speed. The allocated blocks
cannot be freed individually, only all at once. There can be multiple
allocators, though.
*/
/* Returns a new memory allocator or NULL if out of memory. */
tre_mem_t
tre_mem_new_impl
(
int
provided
,
void
*
provided_block
)
{
tre_mem_t
mem
;
if
(
provided
)
{
mem
=
provided_block
;
memset
(
mem
,
0
,
sizeof
(
*
mem
));
}
else
mem
=
xcalloc
(
1
,
sizeof
(
*
mem
));
if
(
mem
==
NULL
)
return
NULL
;
return
mem
;
}
/* Frees the memory allocator and all memory allocated with it. */
void
tre_mem_destroy
(
tre_mem_t
mem
)
{
tre_list_t
*
tmp
,
*
l
=
mem
->
blocks
;
while
(
l
!=
NULL
)
{
xfree
(
l
->
data
);
tmp
=
l
->
next
;
xfree
(
l
);
l
=
tmp
;
}
xfree
(
mem
);
}
/* Allocates a block of `size' bytes from `mem'. Returns a pointer to the
allocated block or NULL if an underlying malloc() failed. */
void
*
tre_mem_alloc_impl
(
tre_mem_t
mem
,
int
provided
,
void
*
provided_block
,
int
zero
,
size_t
size
)
{
void
*
ptr
;
if
(
mem
->
failed
)
{
return
NULL
;
}
if
(
mem
->
n
<
size
)
{
/* We need more memory than is available in the current block.
Allocate a new block. */
tre_list_t
*
l
;
if
(
provided
)
{
if
(
provided_block
==
NULL
)
{
mem
->
failed
=
1
;
return
NULL
;
}
mem
->
ptr
=
provided_block
;
mem
->
n
=
TRE_MEM_BLOCK_SIZE
;
}
else
{
int
block_size
;
if
(
size
*
8
>
TRE_MEM_BLOCK_SIZE
)
block_size
=
size
*
8
;
else
block_size
=
TRE_MEM_BLOCK_SIZE
;
l
=
xmalloc
(
sizeof
(
*
l
));
if
(
l
==
NULL
)
{
mem
->
failed
=
1
;
return
NULL
;
}
l
->
data
=
xmalloc
(
block_size
);
if
(
l
->
data
==
NULL
)
{
xfree
(
l
);
mem
->
failed
=
1
;
return
NULL
;
}
l
->
next
=
NULL
;
if
(
mem
->
current
!=
NULL
)
mem
->
current
->
next
=
l
;
if
(
mem
->
blocks
==
NULL
)
mem
->
blocks
=
l
;
mem
->
current
=
l
;
mem
->
ptr
=
l
->
data
;
mem
->
n
=
block_size
;
}
}
/* Make sure the next pointer will be aligned. */
size
+=
ALIGN
(
mem
->
ptr
+
size
,
long
);
/* Allocate from current block. */
ptr
=
mem
->
ptr
;
mem
->
ptr
+=
size
;
mem
->
n
-=
size
;
/* Set to zero if needed. */
if
(
zero
)
memset
(
ptr
,
0
,
size
);
return
ptr
;
}
porting/liteos_m_iccarm/kernel/src/regex/tre.h
0 → 100644
浏览文件 @
84d0515e
/*
tre-internal.h - TRE internal definitions
Copyright (c) 2001-2009 Ville Laurikari <vl@iki.fi>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <regex.h>
#include <wchar.h>
#include <wctype.h>
#include "../include/features.h"
#undef TRE_MBSTATE
#define NDEBUG
#define TRE_REGEX_T_FIELD __opaque
typedef
int
reg_errcode_t
;
typedef
wchar_t
tre_char_t
;
#define DPRINT(msg) do { } while(0)
#define elementsof(x) ( sizeof(x) / sizeof(x[0]) )
#define tre_mbrtowc(pwc, s, n, ps) (mbtowc((pwc), (s), (n)))
/* Wide characters. */
typedef
wint_t
tre_cint_t
;
#define TRE_CHAR_MAX 0x10ffff
#define tre_isalnum iswalnum
#define tre_isalpha iswalpha
#define tre_isblank iswblank
#define tre_iscntrl iswcntrl
#define tre_isdigit iswdigit
#define tre_isgraph iswgraph
#define tre_islower iswlower
#define tre_isprint iswprint
#define tre_ispunct iswpunct
#define tre_isspace iswspace
#define tre_isupper iswupper
#define tre_isxdigit iswxdigit
#define tre_tolower towlower
#define tre_toupper towupper
#define tre_strlen wcslen
/* Use system provided iswctype() and wctype(). */
typedef
wctype_t
tre_ctype_t
;
#define tre_isctype iswctype
#define tre_ctype wctype
/* Returns number of bytes to add to (char *)ptr to make it
properly aligned for the type. */
#undef ALIGN
#define ALIGN(ptr, type) \
((((long)ptr) % sizeof(type)) \
? (sizeof(type) - (((long)ptr) % sizeof(type))) \
: 0)
#undef MAX
#undef MIN
#define MAX(a, b) (((a) >= (b)) ? (a) : (b))
#define MIN(a, b) (((a) <= (b)) ? (a) : (b))
/* TNFA transition type. A TNFA state is an array of transitions,
the terminator is a transition with NULL `state'. */
typedef
struct
tnfa_transition
tre_tnfa_transition_t
;
struct
tnfa_transition
{
/* Range of accepted characters. */
tre_cint_t
code_min
;
tre_cint_t
code_max
;
/* Pointer to the destination state. */
tre_tnfa_transition_t
*
state
;
/* ID number of the destination state. */
int
state_id
;
/* -1 terminated array of tags (or NULL). */
int
*
tags
;
/* Assertion bitmap. */
int
assertions
;
/* Assertion parameters. */
union
{
/* Character class assertion. */
tre_ctype_t
class
;
/* Back reference assertion. */
int
backref
;
}
u
;
/* Negative character class assertions. */
tre_ctype_t
*
neg_classes
;
};
/* Assertions. */
#define ASSERT_AT_BOL 1
/* Beginning of line. */
#define ASSERT_AT_EOL 2
/* End of line. */
#define ASSERT_CHAR_CLASS 4
/* Character class in `class'. */
#define ASSERT_CHAR_CLASS_NEG 8
/* Character classes in `neg_classes'. */
#define ASSERT_AT_BOW 16
/* Beginning of word. */
#define ASSERT_AT_EOW 32
/* End of word. */
#define ASSERT_AT_WB 64
/* Word boundary. */
#define ASSERT_AT_WB_NEG 128
/* Not a word boundary. */
#define ASSERT_BACKREF 256
/* A back reference in `backref'. */
#define ASSERT_LAST 256
/* Tag directions. */
typedef
enum
{
TRE_TAG_MINIMIZE
=
0
,
TRE_TAG_MAXIMIZE
=
1
}
tre_tag_direction_t
;
/* Instructions to compute submatch register values from tag values
after a successful match. */
struct
tre_submatch_data
{
/* Tag that gives the value for rm_so (submatch start offset). */
int
so_tag
;
/* Tag that gives the value for rm_eo (submatch end offset). */
int
eo_tag
;
/* List of submatches this submatch is contained in. */
int
*
parents
;
};
typedef
struct
tre_submatch_data
tre_submatch_data_t
;
/* TNFA definition. */
typedef
struct
tnfa
tre_tnfa_t
;
struct
tnfa
{
tre_tnfa_transition_t
*
transitions
;
unsigned
int
num_transitions
;
tre_tnfa_transition_t
*
initial
;
tre_tnfa_transition_t
*
final
;
tre_submatch_data_t
*
submatch_data
;
char
*
firstpos_chars
;
int
first_char
;
unsigned
int
num_submatches
;
tre_tag_direction_t
*
tag_directions
;
int
*
minimal_tags
;
int
num_tags
;
int
num_minimals
;
int
end_tag
;
int
num_states
;
int
cflags
;
int
have_backrefs
;
int
have_approx
;
};
/* from tre-mem.h: */
#define TRE_MEM_BLOCK_SIZE 1024
typedef
struct
tre_list
{
void
*
data
;
struct
tre_list
*
next
;
}
tre_list_t
;
typedef
struct
tre_mem_struct
{
tre_list_t
*
blocks
;
tre_list_t
*
current
;
char
*
ptr
;
size_t
n
;
int
failed
;
void
**
provided
;
}
*
tre_mem_t
;
#define tre_mem_new_impl __tre_mem_new_impl
#define tre_mem_alloc_impl __tre_mem_alloc_impl
#define tre_mem_destroy __tre_mem_destroy
hidden
tre_mem_t
tre_mem_new_impl
(
int
provided
,
void
*
provided_block
);
hidden
void
*
tre_mem_alloc_impl
(
tre_mem_t
mem
,
int
provided
,
void
*
provided_block
,
int
zero
,
size_t
size
);
/* Returns a new memory allocator or NULL if out of memory. */
#define tre_mem_new() tre_mem_new_impl(0, NULL)
/* Allocates a block of `size' bytes from `mem'. Returns a pointer to the
allocated block or NULL if an underlying malloc() failed. */
#define tre_mem_alloc(mem, size) tre_mem_alloc_impl(mem, 0, NULL, 0, size)
/* Allocates a block of `size' bytes from `mem'. Returns a pointer to the
allocated block or NULL if an underlying malloc() failed. The memory
is set to zero. */
#define tre_mem_calloc(mem, size) tre_mem_alloc_impl(mem, 0, NULL, 1, size)
#ifdef TRE_USE_ALLOCA
/* alloca() versions. Like above, but memory is allocated with alloca()
instead of malloc(). */
#define tre_mem_newa() \
tre_mem_new_impl(1, alloca(sizeof(struct tre_mem_struct)))
#define tre_mem_alloca(mem, size) \
((mem)->n >= (size) \
? tre_mem_alloc_impl((mem), 1, NULL, 0, (size)) \
: tre_mem_alloc_impl((mem), 1, alloca(TRE_MEM_BLOCK_SIZE), 0, (size)))
#endif
/* TRE_USE_ALLOCA */
/* Frees the memory allocator and all memory allocated with it. */
hidden
void
tre_mem_destroy
(
tre_mem_t
mem
);
#define xmalloc malloc
#define xcalloc calloc
#define xfree free
#define xrealloc realloc
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录