From c9672b8a273cfb7cf5deaab5a1b957cf065712f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Sun, 7 Jun 2015 23:50:16 +0200 Subject: [PATCH] Use unicode to draw borders --- client/mysql.cc | 14 +++++++------- include/sql_string.h | 2 +- sql-common/sql_string.cc | 10 +++++++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index b8240ca..3780a08 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3840,7 +3840,7 @@ print_table_data(MYSQL_RES *result) return; mysql_field_seek(result,0); } - separator.copy("+",1,charset_info); + separator.copy("┼",3,charset_info); while ((field = mysql_fetch_field(result))) { size_t length= column_names ? field->name_length : 0; @@ -3851,15 +3851,15 @@ print_table_data(MYSQL_RES *result) if (length < 4 && !IS_NOT_NULL(field->flags)) length=4; // Room for "NULL" field->max_length=length; - separator.fill(separator.length()+length+2,'-'); - separator.append('+'); + separator.fill((length*3)+separator.length()+6,"─"); + separator.append("┼"); } separator.append(''); // End marker for tee_puts((char*) separator.ptr(), PAGER); if (column_names) { mysql_field_seek(result,0); - (void) tee_fputs("|", PAGER); + (void) tee_fputs("│", PAGER); for (uint off=0; (field = mysql_fetch_field(result)) ; off++) { size_t name_length= strlen(field->name); @@ -3867,7 +3867,7 @@ print_table_data(MYSQL_RES *result) field->name, field->name + name_length); size_t display_length= field->max_length + name_length - numcells; - tee_fprintf(PAGER, " %-*s |", + tee_fprintf(PAGER, " %-*s │", min(display_length, MAX_COLUMN_LENGTH), field->name); num_flag[off]= IS_NUM(field->type); @@ -3881,7 +3881,7 @@ print_table_data(MYSQL_RES *result) if (interrupted_query) break; ulong *lengths= mysql_fetch_lengths(result); - (void) tee_fputs("| ", PAGER); + (void) tee_fputs("│ ", PAGER); mysql_field_seek(result, 0); for (uint off= 0; off < mysql_num_fields(result); off++) { @@ -3928,7 +3928,7 @@ print_table_data(MYSQL_RES *result) else tee_print_sized_data(buffer, data_length, field_max_length+extra_padding, FALSE); } - tee_fputs(" |", PAGER); + tee_fputs(" │", PAGER); } (void) tee_fputs(" ", PAGER); } diff --git a/include/sql_string.h b/include/sql_string.h index 9d96386..166ab8b 100644 --- a/include/sql_string.h +++ b/include/sql_string.h @@ -462,7 +462,7 @@ class String } return 0; } - bool fill(size_t max_length,char fill); + bool fill(size_t max_length,char *fill); void strip_sp(); friend int sortcmp(const String *a,const String *b, const CHARSET_INFO *cs); friend int stringcmp(const String *a,const String *b); diff --git a/sql-common/sql_string.cc b/sql-common/sql_string.cc index 477ed7f..4d7047e 100644 --- a/sql-common/sql_string.cc +++ b/sql-common/sql_string.cc @@ -420,16 +420,20 @@ bool String::set_ascii(const char *str, size_t arg_length) /* This is used by mysql.cc */ -bool String::fill(size_t max_length,char fill_char) +bool String::fill(size_t max_length,char *fill_char) { + uint dummy_errors; if (m_length > max_length) m_ptr[m_length= max_length]= 0; else { if (mem_realloc(max_length)) return true; - memset(m_ptr + m_length, fill_char, max_length - m_length); - m_length= max_length; + while (m_length < max_length) { + m_length+= copy_and_convert(m_ptr + m_length, (uint) strlen(fill_char), m_charset, + fill_char, 4, &my_charset_utf8mb4_general_ci, + &dummy_errors); + } } return false; }