Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
73eee9d8
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
73eee9d8
编写于
5月 28, 2020
作者:
B
Bomin Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix possible dead loop in shellPrintNChar
上级
18bf8f6d
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
36 addition
and
79 deletion
+36
-79
src/kit/shell/inc/shell.h
src/kit/shell/inc/shell.h
+0
-1
src/kit/shell/src/shellDarwin.c
src/kit/shell/src/shellDarwin.c
+0
-25
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+36
-3
src/kit/shell/src/shellLinux.c
src/kit/shell/src/shellLinux.c
+0
-24
src/kit/shell/src/shellWindows.c
src/kit/shell/src/shellWindows.c
+0
-26
未找到文件。
src/kit/shell/inc/shell.h
浏览文件 @
73eee9d8
...
...
@@ -68,7 +68,6 @@ void get_history_path(char* history);
void
cleanup_handler
(
void
*
arg
);
void
exitShell
();
int
shellDumpResult
(
TAOS
*
con
,
char
*
fname
,
int
*
error_no
,
bool
printMode
);
void
shellPrintNChar
(
const
char
*
str
,
int
length
,
int
width
);
void
shellGetGrantInfo
(
void
*
con
);
int
isCommentLine
(
char
*
line
);
...
...
src/kit/shell/src/shellDarwin.c
浏览文件 @
73eee9d8
...
...
@@ -349,31 +349,6 @@ void *shellLoopQuery(void *arg) {
return
NULL
;
}
void
shellPrintNChar
(
const
char
*
str
,
int
length
,
int
width
)
{
int
pos
=
0
,
cols
=
0
;
while
(
pos
<
length
)
{
wchar_t
wc
;
pos
+=
mbtowc
(
&
wc
,
str
+
pos
,
MB_CUR_MAX
);
if
(
pos
>
length
)
{
break
;
}
int
w
=
wcwidth
(
wc
);
if
(
w
>
0
)
{
if
(
width
>
0
&&
cols
+
w
>
width
)
{
break
;
}
printf
(
"%lc"
,
wc
);
cols
+=
w
;
}
}
for
(;
cols
<
width
;
cols
++
)
{
putchar
(
' '
);
}
}
int
get_old_terminal_mode
(
struct
termios
*
tio
)
{
/* Make sure stdin is a terminal. */
if
(
!
isatty
(
STDIN_FILENO
))
{
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
73eee9d8
...
...
@@ -435,7 +435,6 @@ static int dumpResultToFile(const char* fname, TAOS_RES* result) {
int
num_fields
=
taos_num_fields
(
result
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
int32_t
*
length
=
taos_fetch_lengths
(
result
);
int
precision
=
taos_result_precision
(
result
);
for
(
int
col
=
0
;
col
<
num_fields
;
col
++
)
{
...
...
@@ -448,6 +447,7 @@ static int dumpResultToFile(const char* fname, TAOS_RES* result) {
int
numOfRows
=
0
;
do
{
int32_t
*
length
=
taos_fetch_lengths
(
result
);
for
(
int
i
=
0
;
i
<
num_fields
;
i
++
)
{
if
(
i
>
0
)
{
fputc
(
','
,
fp
);
...
...
@@ -465,6 +465,39 @@ static int dumpResultToFile(const char* fname, TAOS_RES* result) {
}
static
void
shellPrintNChar
(
const
char
*
str
,
int
length
,
int
width
)
{
int
pos
=
0
,
cols
=
0
;
while
(
pos
<
length
)
{
wchar_t
wc
;
int
bytes
=
mbtowc
(
&
wc
,
str
+
pos
,
MB_CUR_MAX
);
if
(
bytes
==
0
)
{
break
;
}
pos
+=
bytes
;
if
(
pos
>
length
)
{
break
;
}
#ifdef WINDOWS
int
w
=
bytes
;
#else
int
w
=
wcwidth
(
wc
);
#endif
if
(
w
>
0
)
{
if
(
width
>
0
&&
cols
+
w
>
width
)
{
break
;
}
printf
(
"%lc"
,
wc
);
cols
+=
w
;
}
}
for
(;
cols
<
width
;
cols
++
)
{
putchar
(
' '
);
}
}
static
void
printField
(
const
char
*
val
,
TAOS_FIELD
*
field
,
int
width
,
int32_t
length
,
int
precision
)
{
if
(
val
==
NULL
)
{
int
w
=
width
;
...
...
@@ -523,7 +556,6 @@ static int verticalPrintResult(TAOS_RES* result) {
int
num_fields
=
taos_num_fields
(
result
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
int32_t
*
length
=
taos_fetch_lengths
(
result
);
int
precision
=
taos_result_precision
(
result
);
int
maxColNameLen
=
0
;
...
...
@@ -537,6 +569,7 @@ static int verticalPrintResult(TAOS_RES* result) {
int
numOfRows
=
0
;
do
{
printf
(
"*************************** %d.row ***************************
\n
"
,
numOfRows
+
1
);
int32_t
*
length
=
taos_fetch_lengths
(
result
);
for
(
int
i
=
0
;
i
<
num_fields
;
i
++
)
{
TAOS_FIELD
*
field
=
fields
+
i
;
...
...
@@ -631,7 +664,6 @@ static int horizontalPrintResult(TAOS_RES* result) {
int
num_fields
=
taos_num_fields
(
result
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
int32_t
*
length
=
taos_fetch_lengths
(
result
);
int
precision
=
taos_result_precision
(
result
);
int
width
[
TSDB_MAX_COLUMNS
];
...
...
@@ -643,6 +675,7 @@ static int horizontalPrintResult(TAOS_RES* result) {
int
numOfRows
=
0
;
do
{
int32_t
*
length
=
taos_fetch_lengths
(
result
);
for
(
int
i
=
0
;
i
<
num_fields
;
i
++
)
{
putchar
(
' '
);
printField
(
row
[
i
],
fields
+
i
,
width
[
i
],
length
[
i
],
precision
);
...
...
src/kit/shell/src/shellLinux.c
浏览文件 @
73eee9d8
...
...
@@ -323,30 +323,6 @@ void *shellLoopQuery(void *arg) {
return
NULL
;
}
void
shellPrintNChar
(
const
char
*
str
,
int
length
,
int
width
)
{
int
pos
=
0
,
cols
=
0
;
while
(
pos
<
length
)
{
wchar_t
wc
;
pos
+=
mbtowc
(
&
wc
,
str
+
pos
,
MB_CUR_MAX
);
if
(
pos
>
length
)
{
break
;
}
int
w
=
wcwidth
(
wc
);
if
(
w
>
0
)
{
if
(
width
>
0
&&
cols
+
w
>
width
)
{
break
;
}
printf
(
"%lc"
,
wc
);
cols
+=
w
;
}
}
for
(;
cols
<
width
;
cols
++
)
{
putchar
(
' '
);
}
}
int
get_old_terminal_mode
(
struct
termios
*
tio
)
{
/* Make sure stdin is a terminal. */
if
(
!
isatty
(
STDIN_FILENO
))
{
...
...
src/kit/shell/src/shellWindows.c
浏览文件 @
73eee9d8
...
...
@@ -214,32 +214,6 @@ void *shellLoopQuery(void *arg) {
return
NULL
;
}
void
shellPrintNChar
(
const
char
*
str
,
int
length
,
int
width
)
{
int
pos
=
0
,
cols
=
0
;
while
(
pos
<
length
)
{
wchar_t
wc
;
int
bytes
=
mbtowc
(
&
wc
,
str
+
pos
,
MB_CUR_MAX
);
pos
+=
bytes
;
if
(
pos
>
length
)
{
break
;
}
int
w
=
bytes
;
if
(
w
>
0
)
{
if
(
width
>
0
&&
cols
+
w
>
width
)
{
break
;
}
printf
(
"%lc"
,
wc
);
cols
+=
w
;
}
}
for
(;
cols
<
width
;
cols
++
)
{
putchar
(
' '
);
}
}
void
get_history_path
(
char
*
history
)
{
sprintf
(
history
,
"%s/%s"
,
"."
,
HISTORY_FILE
);
}
void
exitShell
()
{
exit
(
EXIT_SUCCESS
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录