summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-12-09 16:33:48 +0100
committerSergei Golubchik <serg@mariadb.org>2016-12-09 16:33:48 +0100
commit3e8155c637096da8fd019c42b78746be2bf89944 (patch)
tree7df7880c789de7c32fdd76e862170322afe6117c /client
parent106664f8e86d694a9898c3e564bb72290f221bd6 (diff)
parent03dabfa84d6bc9a8197c8d9fbe80f2a7f6a5b6ac (diff)
downloadmariadb-git-3e8155c637096da8fd019c42b78746be2bf89944.tar.gz
Merge branch '5.5' into 10.0
Diffstat (limited to 'client')
-rw-r--r--client/mysqltest.cc26
1 files changed, 21 insertions, 5 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index dede6527d11..ed401b6e4a2 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';
@@ -3391,16 +3391,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);