提交 4e3aa5d5 编写于 作者: B Bomin Zhang

update shellPrintNChar

it padding the output to be exactly  `width` columns now.
上级 3a650da6
......@@ -68,7 +68,7 @@ void get_history_path(char* history);
void cleanup_handler(void* arg);
void exitShell();
int shellDumpResult(TAOS* con, char* fname, int* error_no, bool printMode);
int shellPrintNChar(const char* str, int length, int width);
void shellPrintNChar(const char* str, int length, int width);
void shellGetGrantInfo(void *con);
int isCommentLine(char *line);
......
......@@ -352,7 +352,7 @@ void *shellLoopQuery(void *arg) {
return NULL;
}
int shellPrintNChar(const char *str, int length, int width) {
void shellPrintNChar(const char *str, int length, int width) {
int pos = 0, cols = 0;
while (pos < length) {
wchar_t wc;
......@@ -371,7 +371,9 @@ int shellPrintNChar(const char *str, int length, int width) {
}
}
return cols;
for (; cols < width; cols++) {
putchar(' ');
}
}
......
......@@ -484,9 +484,7 @@ static void printField(const char* val, TAOS_FIELD* field, int width, int32_t le
break;
case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR:
for (int w = shellPrintNChar(val, length, width); w < width; w++) {
putchar(' ');
}
shellPrintNChar(val, length, width);
break;
case TSDB_DATA_TYPE_TIMESTAMP:
formatTimestamp(buf, *(int64_t*)val, precision);
......
......@@ -329,7 +329,7 @@ void *shellLoopQuery(void *arg) {
return NULL;
}
int shellPrintNChar(const char *str, int length, int width) {
void shellPrintNChar(const char *str, int length, int width) {
int pos = 0, cols = 0;
while (pos < length) {
wchar_t wc;
......@@ -348,7 +348,9 @@ int shellPrintNChar(const char *str, int length, int width) {
}
}
return cols;
for (; cols < width; cols++) {
putchar(' ');
}
}
int get_old_terminal_mode(struct termios *tio) {
......
......@@ -217,7 +217,7 @@ void *shellLoopQuery(void *arg) {
return NULL;
}
int shellPrintNChar(const char *str, int length, int width) {
void shellPrintNChar(const char *str, int length, int width) {
int pos = 0, cols = 0;
while (pos < length) {
wchar_t wc;
......@@ -237,7 +237,9 @@ int shellPrintNChar(const char *str, int length, int width) {
}
}
return cols;
for (; cols < width; cols++) {
putchar(' ');
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册