diff options
author | Sergei Golubchik <serg@mariadb.org> | 2016-12-11 09:53:42 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-12-11 09:53:42 +0100 |
commit | 2f20d297f8ea731d845bb220e680ad10c7a927bc (patch) | |
tree | 9bd18ef1ab766422ba4c51b4ab189e259955a2d0 /client | |
parent | a629b5172e96c96c414fca70fffd64c80f2f7e8f (diff) | |
parent | eb4f2e063c341d9f3644339c68cb01679e782001 (diff) | |
download | mariadb-git-2f20d297f8ea731d845bb220e680ad10c7a927bc.tar.gz |
Merge branch '10.0' into 10.1
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqltest.cc | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 0a562904b16..f2c4f9ef867 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -1729,11 +1729,11 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename) while((len= my_read(fd, (uchar*)&buff, sizeof(buff)-1, MYF(0))) > 0) { - char *p= buff, *start= buff; - while (p < buff+len) + char *p= buff, *start= buff,*end=buff+len; + while (p < end) { /* Convert cr/lf to lf */ - if (*p == '\r' && *(p+1) && *(p+1)== '\n') + if (*p == '\r' && p+1 < end && *(p+1)== '\n') { /* Add fake newline instead of cr and output the line */ *p= '\n'; @@ -3389,16 +3389,32 @@ void do_exec(struct st_command *command) ds_result= &ds_sorted; } +#ifdef _WIN32 + /* Workaround for CRT bug, MDEV-9409 */ + _setmode(fileno(res_file), O_BINARY); +#endif + while (fgets(buf, sizeof(buf), res_file)) { + int len = (int)strlen(buf); +#ifdef _WIN32 + /* Strip '\r' off newlines. */ + if (len > 1 && buf[len-2] == '\r' && buf[len-1] == '\n') + { + buf[len-2] = '\n'; + buf[len-1] = 0; + len--; + } +#endif if (disable_result_log) { - buf[strlen(buf)-1]=0; + if (len) + buf[len-1] = 0; DBUG_PRINT("exec_result",("%s", buf)); } else { - replace_dynstr_append(ds_result, buf); + replace_dynstr_append_mem(ds_result, buf, len); } } error= pclose(res_file); |