update shellPrintNChar

it padding the output to be exactly  `width` columns now.
This commit is contained in:
Bomin Zhang 2020-05-25 18:45:43 +08:00
parent 3a650da645
commit 4e3aa5d5d3
5 changed files with 14 additions and 10 deletions

View File

@ -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);

View File

@ -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(' ');
}
}

View File

@ -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);

View File

@ -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) {

View File

@ -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(' ');
}
}