=== modified file 'client/my_readline.h' --- client/my_readline.h 2007-05-10 09:59:39 +0000 +++ client/my_readline.h 2009-01-21 21:39:58 +0000 @@ -29,5 +29,5 @@ extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file); extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str); -extern char *batch_readline(LINE_BUFFER *buffer); +extern char *batch_readline(LINE_BUFFER *buffer, bool *endline = 0); extern void batch_readline_end(LINE_BUFFER *buffer); === modified file 'client/mysql.cc' --- client/mysql.cc 2009-01-05 16:10:20 +0000 +++ client/mysql.cc 2009-01-21 21:32:00 +0000 @@ -1045,7 +1045,7 @@ static COMMANDS *find_command(char *name,char cmd_name); static bool add_line(String &buffer,char *line,char *in_string, - bool *ml_comment); + bool *ml_comment, bool *endline); static void remove_cntrl(String &buffer); static void print_table_data(MYSQL_RES *result); static void print_table_data_html(MYSQL_RES *result); @@ -1808,7 +1808,8 @@ char *line; char in_string=0; ulong line_number=0; - bool ml_comment= 0; + bool ml_comment= 0; + bool endline = 1; COMMANDS *com; status.exit_status=1; @@ -1816,7 +1817,7 @@ { if (!interactive) { - line=batch_readline(status.line_buff); + line=batch_readline(status.line_buff, &endline); /* Skip UTF8 Byte Order Marker (BOM) 0xEFBBBF. Editors like "notepad" put this marker in @@ -1913,7 +1914,7 @@ #endif continue; } - if (add_line(glob_buffer,line,&in_string,&ml_comment)) + if (add_line(glob_buffer,line,&in_string,&ml_comment,&endline)) break; } /* if in batch mode, send last query even if it doesn't end with \g or go */ @@ -1999,7 +2000,7 @@ static bool add_line(String &buffer,char *line,char *in_string, - bool *ml_comment) + bool *ml_comment, bool *endline) { uchar inchar; char buff[80], *pos, *out; @@ -2244,7 +2245,8 @@ } if (out != line || !buffer.is_empty()) { - *out++='\n'; + if (*endline) + *out++='\n'; uint length=(uint) (out-line); if (buffer.length() + length >= buffer.alloced_length()) buffer.realloc(buffer.length()+length+IO_SIZE); === modified file 'client/readline.cc' --- client/readline.cc 2007-05-10 09:59:39 +0000 +++ client/readline.cc 2009-01-21 20:44:09 +0000 @@ -42,16 +42,19 @@ } -char *batch_readline(LINE_BUFFER *line_buff) +char *batch_readline(LINE_BUFFER *line_buff, bool *endline) { char *pos; ulong out_length; if (!(pos=intern_read_line(line_buff,&out_length))) return 0; - if (out_length && pos[out_length-1] == '\n') - if (--out_length && pos[out_length-1] == '\r') /* Remove '\n' */ - out_length--; /* Remove '\r' */ + if (out_length && pos[out_length-1] == '\n') { + if (--out_length && pos[out_length-1] == '\r') /* Remove '\n' */ + out_length--; /* Remove '\r' */ + *endline = 1; + } else + *endline = 0; line_buff->read_length=out_length; pos[out_length]=0; return pos;