Commit c7141fa7 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-13002 mysqltest regex replace results in incorrect result

regex didn't replace lines that were split by 16K chunk reads.
parent c661b4d0
...@@ -1698,12 +1698,22 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename) ...@@ -1698,12 +1698,22 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename)
{ {
int fd; int fd;
size_t len; size_t len;
char buff[16384]; char *buff;
if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0) if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
return 1; return 1;
while((len= my_read(fd, (uchar*)&buff,
sizeof(buff)-1, MYF(0))) > 0) len= (size_t) my_seek(fd, 0, SEEK_END, MYF(0));
my_seek(fd, 0, SEEK_SET, MYF(0));
if (len == (size_t)MY_FILEPOS_ERROR ||
!(buff= (char*)my_malloc(len + 1, MYF(0))))
{
my_close(fd, MYF(0));
return 1;
}
len= my_read(fd, (uchar*)buff, len, MYF(0));
my_close(fd, MYF(0));
{ {
char *p= buff, *start= buff,*end=buff+len; char *p= buff, *start= buff,*end=buff+len;
while (p < end) while (p < end)
...@@ -1726,7 +1736,7 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename) ...@@ -1726,7 +1736,7 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename)
*p= 0; *p= 0;
replace_dynstr_append_mem(ds, start, p-start); replace_dynstr_append_mem(ds, start, p-start);
} }
my_close(fd, MYF(0)); my_free(buff);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment