Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c234adbb
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c234adbb
编写于
6月 22, 2022
作者:
wafwerar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shell: fix shell chinese error
上级
150269b6
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
54 addition
and
20 deletion
+54
-20
include/os/os.h
include/os/os.h
+0
-2
source/common/src/tglobal.c
source/common/src/tglobal.c
+1
-1
source/os/src/osLocale.c
source/os/src/osLocale.c
+2
-2
tests/script/wtest.bat
tests/script/wtest.bat
+1
-1
tools/shell/src/shellCommand.c
tools/shell/src/shellCommand.c
+50
-10
tools/shell/src/shellEngine.c
tools/shell/src/shellEngine.c
+0
-4
未找到文件。
include/os/os.h
浏览文件 @
c234adbb
...
...
@@ -104,8 +104,6 @@ extern "C" {
#include "osTimezone.h"
#include "osEnv.h"
void
osDefaultInit
();
#ifdef __cplusplus
}
#endif
...
...
source/common/src/tglobal.c
浏览文件 @
c234adbb
...
...
@@ -631,7 +631,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
**
envCmd
,
const
char
*
envFile
,
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
osDefaultInit
();
if
(
tsCfg
==
NULL
)
osDefaultInit
();
SConfig
*
pCfg
=
cfgInit
();
if
(
pCfg
==
NULL
)
return
-
1
;
...
...
source/os/src/osLocale.c
浏览文件 @
c234adbb
...
...
@@ -88,11 +88,11 @@ void taosSetSystemLocale(const char *inLocale, const char *inCharSet) {
void
taosGetSystemLocale
(
char
*
outLocale
,
char
*
outCharset
)
{
#ifdef WINDOWS
char
*
locale
=
setlocale
(
LC_CTYPE
,
"
chs
"
);
char
*
locale
=
setlocale
(
LC_CTYPE
,
"
en_US.UTF-8
"
);
if
(
locale
!=
NULL
)
{
tstrncpy
(
outLocale
,
locale
,
TD_LOCALE_LEN
);
}
strcpy
(
outCharset
,
"
cp936
"
);
strcpy
(
outCharset
,
"
UTF-8
"
);
#elif defined(_TD_DARWIN_64)
/*
...
...
tests/script/wtest.bat
浏览文件 @
c234adbb
...
...
@@ -52,7 +52,7 @@ echo wal 0 >> %TAOS_CFG%
echo
asyncLog
0
>>
%TAOS_CFG%
echo
locale
en_US
.UTF
-
8
>>
%TAOS_CFG%
echo
enableCoreFile
1
>>
%TAOS_CFG%
echo
charset
cp65001
>>
%TAOS_CFG%
echo
charset
UTF
-
8
>>
%TAOS_CFG%
set
"FILE_NAME=testSuite.sim"
if
"
%
1"
==
"-f"
set
"FILE_NAME=
%
2"
...
...
tools/shell/src/shellCommand.c
浏览文件 @
c234adbb
...
...
@@ -21,6 +21,7 @@
#define UP 3
#define DOWN 4
#define PSIZE shell.info.promptSize
#define SHELL_INPUT_MAX_COMMAND_SIZE 10000
typedef
struct
{
char
*
buffer
;
...
...
@@ -227,6 +228,7 @@ void shellPrintChar(char c, int32_t times) {
}
void
shellPositionCursor
(
int32_t
step
,
int32_t
direction
)
{
#ifndef WINDOWS
if
(
step
>
0
)
{
if
(
direction
==
LEFT
)
{
fprintf
(
stdout
,
"
\033
[%dD"
,
step
);
...
...
@@ -239,6 +241,7 @@ void shellPositionCursor(int32_t step, int32_t direction) {
}
fflush
(
stdout
);
}
#endif
}
void
shellUpdateBuffer
(
SShellCmd
*
cmd
)
{
...
...
@@ -330,10 +333,14 @@ void shellClearScreen(int32_t ecmd_pos, int32_t cursor_pos) {
int32_t
command_x
=
ecmd_pos
/
ws_col
;
shellPositionCursor
(
cursor_y
,
LEFT
);
shellPositionCursor
(
command_x
-
cursor_x
,
DOWN
);
#ifndef WINDOWS
fprintf
(
stdout
,
"
\033
[2K"
);
#endif
for
(
int32_t
i
=
0
;
i
<
command_x
;
i
++
)
{
shellPositionCursor
(
1
,
UP
);
#ifndef WINDOWS
fprintf
(
stdout
,
"
\033
[2K"
);
#endif
}
fflush
(
stdout
);
}
...
...
@@ -394,6 +401,38 @@ void shellShowOnScreen(SShellCmd *cmd) {
fflush
(
stdout
);
}
char
taosGetConsoleChar
()
{
#ifdef WINDOWS
static
void
*
console
=
NULL
;
if
(
console
==
NULL
)
{
console
=
GetStdHandle
(
STD_INPUT_HANDLE
);
}
static
TdWchar
buf
[
SHELL_INPUT_MAX_COMMAND_SIZE
];
static
char
mbStr
[
5
];
static
unsigned
long
bufLen
=
0
;
static
uint16_t
bufIndex
=
0
,
mbStrIndex
=
0
,
mbStrLen
=
0
;
if
(
bufLen
==
0
)
{
ReadConsoleW
(
console
,
buf
,
SHELL_INPUT_MAX_COMMAND_SIZE
,
&
bufLen
,
NULL
);
bufIndex
=
0
;
}
if
(
mbStrLen
==
0
){
mbStrLen
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
&
buf
[
bufIndex
],
1
,
mbStr
,
sizeof
(
mbStr
),
NULL
,
NULL
);
mbStrIndex
=
0
;
bufIndex
++
;
}
mbStrIndex
++
;
if
(
mbStrIndex
==
mbStrLen
)
{
mbStrLen
=
0
;
if
(
bufIndex
==
bufLen
)
{
bufLen
=
0
;
}
}
return
mbStr
[
mbStrIndex
-
1
];
#else
return
(
char
)
getchar
();
// getchar() return an 'int32_t' value
#endif
}
int32_t
shellReadCommand
(
char
*
command
)
{
SShellHistory
*
pHistory
=
&
shell
.
history
;
SShellCmd
cmd
=
{
0
};
...
...
@@ -407,7 +446,7 @@ int32_t shellReadCommand(char *command) {
// Read input.
char
c
;
while
(
1
)
{
c
=
(
char
)
getchar
();
// getchar() return an 'int32_t' value
c
=
taosGetConsoleChar
();
if
(
c
==
EOF
)
{
return
c
;
...
...
@@ -417,7 +456,7 @@ int32_t shellReadCommand(char *command) {
int32_t
count
=
shellCountPrefixOnes
(
c
);
utf8_array
[
0
]
=
c
;
for
(
int32_t
k
=
1
;
k
<
count
;
k
++
)
{
c
=
(
char
)
getc
har
();
c
=
taosGetConsoleC
har
();
utf8_array
[
k
]
=
c
;
}
shellInsertChar
(
&
cmd
,
utf8_array
,
count
);
...
...
@@ -446,6 +485,7 @@ int32_t shellReadCommand(char *command) {
shellBackspaceChar
(
&
cmd
);
break
;
case
'\n'
:
break
;
case
'\r'
:
#ifdef WINDOWS
#else
...
...
@@ -472,10 +512,10 @@ int32_t shellReadCommand(char *command) {
break
;
}
}
else
if
(
c
==
'\033'
)
{
c
=
(
char
)
getc
har
();
c
=
taosGetConsoleC
har
();
switch
(
c
)
{
case
'['
:
c
=
(
char
)
getc
har
();
c
=
taosGetConsoleC
har
();
switch
(
c
)
{
case
'A'
:
// Up arrow
if
(
hist_counter
!=
pHistory
->
hstart
)
{
...
...
@@ -502,35 +542,35 @@ int32_t shellReadCommand(char *command) {
shellMoveCursorLeft
(
&
cmd
);
break
;
case
'1'
:
if
((
c
=
(
char
)
getc
har
())
==
'~'
)
{
if
((
c
=
taosGetConsoleC
har
())
==
'~'
)
{
// Home key
shellPositionCursorHome
(
&
cmd
);
}
break
;
case
'2'
:
if
((
c
=
(
char
)
getc
har
())
==
'~'
)
{
if
((
c
=
taosGetConsoleC
har
())
==
'~'
)
{
// Insert key
}
break
;
case
'3'
:
if
((
c
=
(
char
)
getc
har
())
==
'~'
)
{
if
((
c
=
taosGetConsoleC
har
())
==
'~'
)
{
// Delete key
shellDeleteChar
(
&
cmd
);
}
break
;
case
'4'
:
if
((
c
=
(
char
)
getc
har
())
==
'~'
)
{
if
((
c
=
taosGetConsoleC
har
())
==
'~'
)
{
// End key
shellPositionCursorEnd
(
&
cmd
);
}
break
;
case
'5'
:
if
((
c
=
(
char
)
getc
har
())
==
'~'
)
{
if
((
c
=
taosGetConsoleC
har
())
==
'~'
)
{
// Page up key
}
break
;
case
'6'
:
if
((
c
=
(
char
)
getc
har
())
==
'~'
)
{
if
((
c
=
taosGetConsoleC
har
())
==
'~'
)
{
// Page down key
}
break
;
...
...
tools/shell/src/shellEngine.c
浏览文件 @
c234adbb
...
...
@@ -393,15 +393,11 @@ void shellPrintNChar(const char *str, int32_t length, int32_t width) {
break
;
}
int
w
=
0
;
#ifdef WINDOWS
w
=
bytes
;
#else
if
(
*
(
str
+
pos
)
==
'\t'
||
*
(
str
+
pos
)
==
'\n'
||
*
(
str
+
pos
)
==
'\r'
){
w
=
bytes
;
}
else
{
w
=
taosWcharWidth
(
wc
);
}
#endif
pos
+=
bytes
;
if
(
w
<=
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录