Commit ff3f735c authored by jimw@mysql.com's avatar jimw@mysql.com

Merge jwinstead@production.mysql.com:my/mysql-4.1-10840

into  mysql.com:/home/jimw/my/mysql-4.1-clean
parents 481f7632 e4cb7947
...@@ -931,6 +931,7 @@ static int read_lines(bool execute_commands) ...@@ -931,6 +931,7 @@ static int read_lines(bool execute_commands)
{ {
#if defined( __WIN__) || defined(OS2) || defined(__NETWARE__) #if defined( __WIN__) || defined(OS2) || defined(__NETWARE__)
char linebuffer[254]; char linebuffer[254];
String buffer;
#endif #endif
char *line; char *line;
char in_string=0; char in_string=0;
...@@ -972,8 +973,24 @@ static int read_lines(bool execute_commands) ...@@ -972,8 +973,24 @@ static int read_lines(bool execute_commands)
*p = '\0'; *p = '\0';
} }
#else #else
linebuffer[0]= (char) sizeof(linebuffer); buffer.length(0);
line= _cgets(linebuffer); /* _cgets() expects the buffer size - 3 as the first byte */
linebuffer[0]= (char) sizeof(linebuffer) - 3;
do
{
line= _cgets(linebuffer);
buffer.append(line, (unsigned char)linebuffer[1]);
/*
If _cgets() gets an input line that is linebuffer[0] bytes
long, the next call to _cgets() will return immediately with
linebuffer[1] == 0, and it does the same thing for input that
is linebuffer[0]-1 bytes long. So it appears that even though
_cgets() replaces the newline (which is two bytes on Window) with
a nil, it still needs the space in the linebuffer for it. This is,
naturally, undocumented.
*/
} while (linebuffer[0] <= linebuffer[1] + 1);
line= buffer.c_ptr();
#endif /* __NETWARE__ */ #endif /* __NETWARE__ */
#else #else
if (opt_outfile) if (opt_outfile)
...@@ -1030,6 +1047,9 @@ static int read_lines(bool execute_commands) ...@@ -1030,6 +1047,9 @@ static int read_lines(bool execute_commands)
status.exit_status=0; status.exit_status=0;
} }
} }
#if defined( __WIN__) || defined(OS2) || defined(__NETWARE__)
buffer.free();
#endif
return status.exit_status; return status.exit_status;
} }
......
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