Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Keyboard Man_俊
rt-thread
提交
a5ba2a24
R
rt-thread
项目概览
Keyboard Man_俊
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a5ba2a24
编写于
1月 01, 2014
作者:
B
bernard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add file and path name auto completion for module shell
上级
a93251ae
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
341 addition
and
237 deletion
+341
-237
components/finsh/finsh.h
components/finsh/finsh.h
+164
-187
components/finsh/msh.c
components/finsh/msh.c
+144
-8
components/finsh/msh_cmd.c
components/finsh/msh_cmd.c
+11
-14
components/finsh/shell.c
components/finsh/shell.c
+9
-9
include/rtdef.h
include/rtdef.h
+13
-19
未找到文件。
components/finsh/finsh.h
浏览文件 @
a5ba2a24
...
...
@@ -178,117 +178,48 @@ struct finsh_sysvar* finsh_sysvar_lookup(const char* name);
#ifdef FINSH_USING_SYMTAB
#ifdef __TI_COMPILER_VERSION__
#define _EMIT_PRAGMA(x) _Pragma(#x)
#define __TI_FINSH_EXPORT_FUNCTION(f) _EMIT_PRAGMA(DATA_SECTION(f,"FSymTab"))
#define __TI_FINSH_EXPORT_VAR(v) _EMIT_PRAGMA(DATA_SECTION(v,"VSymTab"))
#define __TI_FINSH_EXPORT_FUNCTION(f) PRAGMA(DATA_SECTION(f,"FSymTab"))
#define __TI_FINSH_EXPORT_VAR(v) PRAGMA(DATA_SECTION(v,"VSymTab"))
#endif
#ifdef FINSH_USING_DESCRIPTION
/**
* @ingroup finsh
*
* This macro exports a system function to finsh shell.
*
* @param name the name of function.
* @param desc the description of function, which will show in help.
*/
#ifdef _MSC_VER
#define FINSH_FUNCTION_EXPORT(name, desc) \
const char __fsym_##name##_name[] = #name; \
const char __fsym_##name##_desc[] = #desc; \
__declspec(allocate("FSymTab$f")) const struct finsh_syscall __fsym_##name = \
#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
const char __fsym_##cmd##_name[] = #cmd; \
const char __fsym_##cmd##_desc[] = #desc; \
__declspec(allocate("FSymTab$f")) \
const struct finsh_syscall __fsym_##cmd = \
{ \
__fsym_##name##_name,
\
__fsym_##name##_desc,
\
__fsym_##cmd##_name,
\
__fsym_##cmd##_desc,
\
(syscall_func)&name \
};
#pragma comment(linker, "/merge:FSymTab=mytext")
#elif defined(__TI_COMPILER_VERSION__)
#define FINSH_FUNCTION_EXPORT(name, desc) \
__TI_FINSH_EXPORT_FUNCTION(__fsym_##name); \
const char __fsym_##name##_name[] = #name; \
const char __fsym_##name##_desc[] = #desc; \
const struct finsh_syscall __fsym_##name = \
{ \
__fsym_##name##_name, \
__fsym_##name##_desc, \
(syscall_func)&name \
};
#else
#define FINSH_FUNCTION_EXPORT(name, desc) \
const char __fsym_##name##_name[] = #name; \
const char __fsym_##name##_desc[] = #desc; \
const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \
{ \
__fsym_##name##_name, \
__fsym_##name##_desc, \
(syscall_func)&name \
};
#endif
/* FINSH_FUNCTION_EXPORT defines */
/**
* @ingroup finsh
*
* This macro exports a system function with an alias name to finsh shell.
*
* @param name the name of function.
* @param alias the alias name of function.
* @param desc the description of function, which will show in help.
*/
#ifdef _MSC_VER
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \
const char __fsym_##alias##_name[] = #alias; \
const char __fsym_##alias##_desc[] = #desc; \
__declspec(allocate("FSymTab$f")) \
const struct finsh_syscall __fsym_##alias = \
{ \
__fsym_##alias##_name, \
__fsym_##alias##_desc, \
(syscall_func)&name \
};
#elif defined(__TI_COMPILER_VERSION__)
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \
__TI_FINSH_EXPORT_FUNCTION(__fsym_##alias); \
const char __fsym_##alias##_name[] = #alias; \
const char __fsym_##alias##_desc[] = #desc; \
const struct finsh_syscall __fsym_##alias = \
{ \
__fsym_##alias##_name, \
__fsym_##alias##_desc, \
(syscall_func)&name \
};
#else
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \
const char __fsym_##alias##_name[] = #alias; \
const char __fsym_##alias##_desc[] = #desc; \
const struct finsh_syscall __fsym_##alias SECTION("FSymTab")= \
{ \
__fsym_##alias##_name, \
__fsym_##alias##_desc, \
(syscall_func)&name \
};
#endif
/* FINSH_FUNCTION_EXPORT_ALIAS defines */
/**
* @ingroup finsh
*
* This macro exports a variable to finsh shell.
*
* @param name the name of function.
* @param type the type of variable.
* @param desc the description of function, which will show in help.
*/
#ifdef _MSC_VER
#define FINSH_VAR_EXPORT(name, type, desc) \
const char __vsym_##name##_name[] = #name; \
const char __vsym_##name##_desc[] = #desc; \
__declspec(allocate("VSymTab")) const struct finsh_sysvar __vsym_##name = \
__declspec(allocate("VSymTab")) \
const struct finsh_sysvar __vsym_##name = \
{ \
__vsym_##name##_name, \
__vsym_##name##_desc, \
type, \
(void*)&name \
};
#elif defined(__TI_COMPILER_VERSION__)
#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
__TI_FINSH_EXPORT_FUNCTION(__fsym_##cmd); \
const char __fsym_##cmd##_name[] = #cmd; \
const char __fsym_##cmd##_desc[] = #desc; \
const struct finsh_syscall __fsym_##cmd = \
{ \
__fsym_##cmd##_name, \
__fsym_##cmd##_desc, \
(syscall_func)&name \
};
#define FINSH_VAR_EXPORT(name, type, desc) \
__TI_FINSH_EXPORT_VAR(__vsym_##name); \
const char __vsym_##name##_name[] = #name; \
...
...
@@ -300,7 +231,18 @@ struct finsh_sysvar* finsh_sysvar_lookup(const char* name);
type, \
(void*)&name \
};
#else
#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
const char __fsym_##cmd##_name[] = #cmd; \
const char __fsym_##cmd##_desc[] = #desc; \
const struct finsh_syscall __fsym_##cmd SECTION("FSymTab")= \
{ \
__fsym_##cmd##_name, \
__fsym_##cmd##_desc, \
(syscall_func)&name \
};
#define FINSH_VAR_EXPORT(name, type, desc) \
const char __vsym_##name##_name[] = #name; \
const char __vsym_##name##_desc[] = #desc; \
...
...
@@ -311,25 +253,36 @@ struct finsh_sysvar* finsh_sysvar_lookup(const char* name);
type, \
(void*)&name \
};
#endif
/* FINSH_VAR_EXPORT defines */
#else
/* FINSH_USING_DESCRIPTION */
#if defined(__TI_COMPILER_VERSION__)
#define FINSH_FUNCTION_EXPORT(name, desc) \
__TI_FINSH_EXPORT_FUNCTION(__fsym_##name);
\
const char __fsym_##name##_name[] = #name;
\
const char __fsym_##name##_desc[] = #desc;
\
const struct finsh_syscall __fsym_##name =
\
#endif
#else
#ifdef _MSC_VER
#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc)
\
const char __fsym_##cmd##_name[] = #cmd;
\
__declspec(allocate("FSymTab$f"))
\
const struct finsh_syscall __fsym_##cmd =
\
{ \
__fsym_##name##_name, \
__fsym_##name##_desc, \
__fsym_##cmd##_name, \
(syscall_func)&name \
};
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \
const char __fsym_##alias##_name[] = #alias; \
__TI_FINSH_EXPORT_FUNCTION(__fsym_##alias); \
const struct finsh_syscall __fsym_##alias = \
#pragma comment(linker, "/merge:FSymTab=mytext")
#define FINSH_VAR_EXPORT(name, type, desc) \
const char __vsym_##name##_name[] = #name; \
__declspec(allocate("VSymTab")) const struct finsh_sysvar __vsym_##name = \
{ \
__vsym_##name##_name, \
type, \
(void*)&name \
};
#elif defined(__TI_COMPILER_VERSION__)
#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
__TI_FINSH_EXPORT_FUNCTION(__fsym_##cmd); \
const char __fsym_##cmd##_name[] = #cmd; \
const struct finsh_syscall __fsym_##cmd = \
{ \
__fsym_##alias##_name,
\
__fsym_##cmd##_name,
\
(syscall_func)&name \
};
...
...
@@ -342,20 +295,13 @@ struct finsh_sysvar* finsh_sysvar_lookup(const char* name);
type, \
(void*)&name \
};
#else
#define FINSH_FUNCTION_EXPORT(name, desc) \
const char __fsym_##name##_name[] = #name; \
const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \
{ \
__fsym_##name##_name, \
(syscall_func)&name \
};
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \
const char __fsym_##alias##_name[] = #alias; \
const struct finsh_syscall __fsym_##alias SECTION("FSymTab")= \
#else
#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc) \
const char __fsym_##cmd##_name[] = #cmd; \
const struct finsh_syscall __fsym_##cmd SECTION("FSymTab")= \
{ \
__fsym_##alias##_name,
\
__fsym_##cmd##_name,
\
(syscall_func)&name \
};
...
...
@@ -367,13 +313,44 @@ struct finsh_sysvar* finsh_sysvar_lookup(const char* name);
type, \
(void*)&name \
};
#endif
/* __TI_COMPILER_VERSION__ */
#endif
/* FINSH_USING_DESCRIPTION */
#else
#define FINSH_FUNCTION_EXPORT(name, desc)
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc)
#define FINSH_VAR_EXPORT(name, type, desc)
#endif
#endif
#endif
/* end of FINSH_USING_DESCRIPTION */
#endif
/* end of FINSH_USING_SYMTAB */
/**
* @ingroup finsh
*
* This macro exports a system function to finsh shell.
*
* @param name the name of function.
* @param desc the description of function, which will show in help.
*/
#define FINSH_FUNCTION_EXPORT(name, desc) \
FINSH_FUNCTION_EXPORT_CMD(name, name, desc)
/**
* @ingroup finsh
*
* This macro exports a system function with an alias name to finsh shell.
*
* @param name the name of function.
* @param alias the alias name of function.
* @param desc the description of function, which will show in help.
*/
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \
FINSH_FUNCTION_EXPORT_CMD(name, alias, desc)
/**
* @ingroup finsh
*
* This macro exports a command to module shell.
*
* @param command the name of command.
* @param desc the description of command, which will show in help.
*/
#define MSH_CMD_EXPORT(command, desc) \
FINSH_FUNCTION_EXPORT_CMD(command, __cmd_##command, desc)
struct
finsh_token
{
...
...
components/finsh/msh.c
浏览文件 @
a5ba2a24
...
...
@@ -73,15 +73,18 @@ int msh_help(int argc, char** argv)
FINSH_NEXT_SYSCALL
(
index
))
{
if
(
strncmp
(
index
->
name
,
"__cmd_"
,
6
)
!=
0
)
continue
;
#if defined(FINSH_USING_DESCRIPTION) && defined(FINSH_USING_SYMTAB)
rt_kprintf
(
"%-16s - %s
\n
"
,
&
index
->
name
[
6
],
index
->
desc
);
#else
rt_kprintf
(
"%s "
,
&
index
->
name
[
6
]);
#endif
}
}
rt_kprintf
(
"
\n
"
);
return
0
;
}
FINSH_FUNCTION_EXPORT_ALIAS
(
msh_help
,
__cmd_help
,
"RT-Thread shell help."
);
FINSH_FUNCTION_EXPORT_ALIAS
(
msh_help
,
__cmd_help
,
RT
-
Thread
shell
help
.
);
static
int
msh_split
(
char
*
cmd
,
rt_size_t
length
,
char
*
argv
[
RT_FINSH_ARG_MAX
])
{
...
...
@@ -197,14 +200,130 @@ static int str_common(const char *str1, const char *str2)
return
(
str
-
str1
);
}
#ifdef RT_USING_DFS
#include <dfs_posix.h>
void
msh_auto_complete_path
(
char
*
path
)
{
DIR
*
dir
;
struct
dirent
*
dirent
;
char
*
full_path
,
*
ptr
,
*
index
;
full_path
=
(
char
*
)
rt_malloc
(
256
);
if
(
full_path
==
RT_NULL
)
return
;
/* out of memory */
ptr
=
full_path
;
if
(
*
path
!=
'/'
)
{
getcwd
(
full_path
,
256
);
if
(
full_path
[
rt_strlen
(
full_path
)
-
1
]
!=
'/'
)
strcat
(
full_path
,
"/"
);
}
else
*
full_path
=
'\0'
;
index
=
RT_NULL
;
ptr
=
path
;
for
(;;)
{
if
(
*
ptr
==
'/'
)
index
=
ptr
+
1
;
if
(
!*
ptr
)
break
;
ptr
++
;
}
if
(
index
==
RT_NULL
)
index
=
path
;
if
(
index
!=
RT_NULL
)
{
char
*
dest
=
index
;
/* fill the parent path */
ptr
=
full_path
;
while
(
*
ptr
)
ptr
++
;
for
(
index
=
path
;
index
!=
dest
;)
*
ptr
++
=
*
index
++
;
*
ptr
=
'\0'
;
dir
=
opendir
(
full_path
);
if
(
dir
==
RT_NULL
)
/* open directory failed! */
{
rt_free
(
full_path
);
return
;
}
/* restore the index position */
index
=
dest
;
}
/* auto complete the file or directory name */
if
(
*
index
==
'\0'
)
/* display all of files and directories */
{
for
(;;)
{
dirent
=
readdir
(
dir
);
if
(
dirent
==
RT_NULL
)
break
;
rt_kprintf
(
"%s
\n
"
,
dirent
->
d_name
);
}
}
else
{
int
length
,
min_length
;
min_length
=
0
;
for
(;;)
{
dirent
=
readdir
(
dir
);
if
(
dirent
==
RT_NULL
)
break
;
/* matched the prefix string */
if
(
strncmp
(
index
,
dirent
->
d_name
,
rt_strlen
(
index
))
==
0
)
{
if
(
min_length
==
0
)
{
min_length
=
rt_strlen
(
dirent
->
d_name
);
/* save dirent name */
strcpy
(
full_path
,
dirent
->
d_name
);
}
length
=
str_common
(
dirent
->
d_name
,
full_path
);
if
(
length
<
min_length
)
{
min_length
=
length
;
}
}
}
if
(
min_length
)
{
if
(
min_length
<
rt_strlen
(
full_path
))
{
/* list the candidate */
rewinddir
(
dir
);
for
(;;)
{
dirent
=
readdir
(
dir
);
if
(
dirent
==
RT_NULL
)
break
;
if
(
strncmp
(
index
,
dirent
->
d_name
,
rt_strlen
(
index
))
==
0
)
rt_kprintf
(
"%s
\n
"
,
dirent
->
d_name
);
}
}
length
=
index
-
path
;
memcpy
(
index
,
full_path
,
min_length
);
path
[
length
+
min_length
]
=
'\0'
;
}
}
closedir
(
dir
);
rt_free
(
full_path
);
}
#endif
void
msh_auto_complete
(
char
*
prefix
)
{
rt_uint16_t
func_cnt
;
int
length
,
min_length
;
const
char
*
name_ptr
,
*
cmd_name
;
struct
finsh_syscall
*
index
;
func_cnt
=
0
;
min_length
=
0
;
name_ptr
=
RT_NULL
;
...
...
@@ -214,6 +333,25 @@ void msh_auto_complete(char *prefix)
return
;
}
#ifdef RT_USING_DFS
/* check whether a spare in the command */
{
char
*
ptr
;
ptr
=
prefix
+
rt_strlen
(
prefix
);
while
(
ptr
!=
prefix
)
{
if
(
*
ptr
==
' '
)
{
msh_auto_complete_path
(
ptr
+
1
);
break
;
}
ptr
--
;
}
}
#endif
/* checks in internal command */
{
for
(
index
=
_syscall_table_begin
;
index
<
_syscall_table_end
;
FINSH_NEXT_SYSCALL
(
index
))
...
...
@@ -224,17 +362,14 @@ void msh_auto_complete(char *prefix)
cmd_name
=
(
const
char
*
)
&
index
->
name
[
6
];
if
(
strncmp
(
prefix
,
cmd_name
,
strlen
(
prefix
))
==
0
)
{
if
(
func_cnt
==
0
)
if
(
min_length
==
0
)
{
/* set name_ptr */
name_ptr
=
cmd_name
;
/* set initial length */
min_length
=
strlen
(
name_ptr
);
}
func_cnt
++
;
length
=
str_common
(
name_ptr
,
cmd_name
);
if
(
length
<
min_length
)
min_length
=
length
;
...
...
@@ -253,3 +388,4 @@ void msh_auto_complete(char *prefix)
return
;
}
#endif
components/finsh/msh_cmd.c
浏览文件 @
a5ba2a24
...
...
@@ -59,7 +59,7 @@ int cmd_ls(int argc, char** argv)
return
0
;
}
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_ls
,
__cmd_ls
,
"List information about the FILEs."
);
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_ls
,
__cmd_ls
,
List
information
about
the
FILEs
.
);
int
cmd_cp
(
int
argc
,
char
**
argv
)
{
...
...
@@ -77,7 +77,7 @@ int cmd_cp(int argc, char** argv)
return
0
;
}
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_cp
,
__cmd_cp
,
"Copy SOURCE to DEST."
);
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_cp
,
__cmd_cp
,
Copy
SOURCE
to
DEST
.
);
int
cmd_mv
(
int
argc
,
char
**
argv
)
{
...
...
@@ -89,11 +89,12 @@ int cmd_mv(int argc, char** argv)
else
{
rt_kprintf
(
"%s => %s
\n
"
,
argv
[
1
],
argv
[
2
]);
rename
(
argv
[
1
],
argv
[
2
]);
}
return
0
;
}
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_mv
,
__cmd_mv
,
"Rename SOURCE to DEST."
);
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_mv
,
__cmd_mv
,
Rename
SOURCE
to
DEST
.
);
int
cmd_cat
(
int
argc
,
char
**
argv
)
{
...
...
@@ -114,7 +115,7 @@ int cmd_cat(int argc, char** argv)
return
0
;
}
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_cat
,
__cmd_cat
,
"Concatenate FILE(s)"
);
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_cat
,
__cmd_cat
,
Concatenate
FILE
(
s
)
);
int
cmd_rm
(
int
argc
,
char
**
argv
)
{
...
...
@@ -134,7 +135,7 @@ int cmd_rm(int argc, char** argv)
return
0
;
}
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_rm
,
__cmd_rm
,
"Remove (unlink) the FILE(s)."
);
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_rm
,
__cmd_rm
,
Remove
(
unlink
)
the
FILE
(
s
).
);
#ifdef DFS_USING_WORKDIR
int
cmd_cd
(
int
argc
,
char
**
argv
)
...
...
@@ -185,19 +186,14 @@ int cmd_ps(int argc, char** argv)
list_thread
();
return
0
;
}
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_ps
,
__cmd_ps
,
"list threads in the system"
);
int
cmd_i
(
int
argc
,
char
**
argv
)
{
return
cmd_ps
(
argc
,
argv
);
}
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_i
,
__cmd_i
,
"list threads in the system"
);
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_ps
,
__cmd_ps
,
List
threads
in
the
system
.);
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_ps
,
__cmd_i
,
List
threads
in
the
system
.);
int
cmd_time
(
int
argc
,
char
**
argv
)
{
return
0
;
}
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_time
,
__cmd_time
,
"exec command with time"
);
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_time
,
__cmd_time
,
Execute
command
with
time
.
);
int
cmd_free
(
int
argc
,
char
**
argv
)
{
...
...
@@ -206,6 +202,7 @@ int cmd_free(int argc, char** argv)
list_mem
();
return
0
;
}
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_free
,
__cmd_free
,
"show the memory usage in the system"
);
FINSH_FUNCTION_EXPORT_ALIAS
(
cmd_free
,
__cmd_free
,
Show
the
memory
usage
in
the
system
.
);
#endif
components/finsh/shell.c
浏览文件 @
a5ba2a24
...
...
@@ -181,7 +181,7 @@ rt_uint32_t finsh_get_echo()
return
shell
->
echo_mode
;
}
void
finsh
_auto_complete
(
char
*
prefix
)
static
void
shell
_auto_complete
(
char
*
prefix
)
{
extern
void
list_prefix
(
char
*
prefix
);
...
...
@@ -244,7 +244,7 @@ void finsh_run_line(struct finsh_parser* parser, const char *line)
}
#ifdef FINSH_USING_HISTORY
rt_bool_t
finsh
_handle_history
(
struct
finsh_shell
*
shell
)
static
rt_bool_t
shell
_handle_history
(
struct
finsh_shell
*
shell
)
{
#if defined(_WIN32)
int
i
;
...
...
@@ -261,7 +261,7 @@ rt_bool_t finsh_handle_history(struct finsh_shell* shell)
return
RT_FALSE
;
}
void
finsh
_push_history
(
struct
finsh_shell
*
shell
)
static
void
shell
_push_history
(
struct
finsh_shell
*
shell
)
{
if
(
shell
->
line_position
!=
0
)
{
...
...
@@ -370,7 +370,7 @@ void finsh_thread_entry(void* parameter)
memcpy
(
shell
->
line
,
&
shell
->
cmd_history
[
shell
->
current_history
][
0
],
FINSH_CMD_SIZE
);
shell
->
line_curpos
=
shell
->
line_position
=
strlen
(
shell
->
line
);
finsh
_handle_history
(
shell
);
shell
_handle_history
(
shell
);
#endif
continue
;
}
...
...
@@ -392,7 +392,7 @@ void finsh_thread_entry(void* parameter)
memcpy
(
shell
->
line
,
&
shell
->
cmd_history
[
shell
->
current_history
][
0
],
FINSH_CMD_SIZE
);
shell
->
line_curpos
=
shell
->
line_position
=
strlen
(
shell
->
line
);
finsh
_handle_history
(
shell
);
shell
_handle_history
(
shell
);
#endif
continue
;
}
...
...
@@ -437,7 +437,7 @@ void finsh_thread_entry(void* parameter)
rt_kprintf
(
"
\b
"
);
/* auto complete */
finsh
_auto_complete
(
&
shell
->
line
[
0
]);
shell
_auto_complete
(
&
shell
->
line
[
0
]);
/* re-calculate position */
shell
->
line_curpos
=
shell
->
line_position
=
strlen
(
shell
->
line
);
...
...
@@ -484,10 +484,10 @@ void finsh_thread_entry(void* parameter)
if
(
msh_is_used
()
==
RT_TRUE
&&
shell
->
line_position
!=
0
)
{
rt_kprintf
(
"
\n
"
);
msh_exec
(
shell
->
line
,
shell
->
line_position
);
#ifdef FINSH_USING_HISTORY
finsh
_push_history
(
shell
);
shell
_push_history
(
shell
);
#endif
msh_exec
(
shell
->
line
,
shell
->
line_position
);
}
else
#endif
...
...
@@ -496,7 +496,7 @@ void finsh_thread_entry(void* parameter)
shell
->
line
[
shell
->
line_position
]
=
';'
;
#ifdef FINSH_USING_HISTORY
finsh
_push_history
(
shell
);
shell
_push_history
(
shell
);
#endif
if
(
shell
->
line_position
!=
0
)
finsh_run_line
(
&
shell
->
parser
,
shell
->
line
);
...
...
include/rtdef.h
浏览文件 @
a5ba2a24
...
...
@@ -117,26 +117,13 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#ifdef RT_USING_NEWLIB
#include <stdarg.h>
#else
#if __GNUC__ < 4
typedef
void
*
__sys_va_list
;
typedef
__sys_va_list
va_list
;
#define __va_rounded_size(type) \
(((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
#define va_start(ap, lastarg) \
(ap = ((char *) &(lastarg) + __va_rounded_size(lastarg)))
#define va_end(ap) ((void)0)
/* little endian */
#define va_arg(ap, type) \
(ap = (__sys_va_list) ((char *)(ap) + __va_rounded_size(type)), \
*((type *) (void *) ((char *)(ap) - __va_rounded_size(type))))
#else
/* the version of GNU GCC must be greater than 4.x */
typedef
__builtin_va_list
__gnuc_va_list
;
typedef
__gnuc_va_list
va_list
;
#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)
#endif
#endif
#define SECTION(x) __attribute__((section(x)))
#define UNUSED __attribute__((unused))
...
...
@@ -168,6 +155,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define SECTION(x)
#define UNUSED
#define USED
#define PRAGMA(x) _Pragma(#x)
#define ALIGN(n)
#define rt_inline static inline
#define RTT_API
...
...
@@ -214,6 +202,12 @@ typedef int (*init_fn_t)(void);
/* appliation initialization (rtgui application etc ...) */
#define INIT_APP_EXPORT(fn) INIT_EXPORT(fn, "6")
#if !defined(RT_USING_FINSH)
/* define these to empty, even if not include finsh.h file */
#define FINSH_FUNCTION_EXPORT_CMD(name, cmd, desc)
#define FINSH_VAR_EXPORT(name, type, desc)
#endif
/* event length */
#define RT_EVENT_LENGTH 32
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录