Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use unicode to draw borders #11

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -3851,23 +3851,23 @@ 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('\0'); // End marker for \0
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);
size_t numcells= charset_info->cset->numcells(charset_info,
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<int>(display_length, MAX_COLUMN_LENGTH),
field->name);
num_flag[off]= IS_NUM(field->type);
Expand All @@ -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++)
{
Expand Down Expand Up @@ -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("\n", PAGER);
}
Expand Down
2 changes: 1 addition & 1 deletion include/sql_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 7 additions & 3 deletions sql-common/sql_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down