mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
8261949: fileStream::readln returns incorrect line string
Reviewed-by: dcubed, dholmes
This commit is contained in:
parent
539c80bfda
commit
2b55501519
1 changed files with 5 additions and 2 deletions
|
@ -589,8 +589,11 @@ char* fileStream::readln(char *data, int count ) {
|
||||||
char * ret = NULL;
|
char * ret = NULL;
|
||||||
if (_file != NULL) {
|
if (_file != NULL) {
|
||||||
ret = ::fgets(data, count, _file);
|
ret = ::fgets(data, count, _file);
|
||||||
//Get rid of annoying \n char
|
// Get rid of annoying \n char only if it is present.
|
||||||
data[::strlen(data)-1] = '\0';
|
size_t len = ::strlen(data);
|
||||||
|
if (len > 0 && data[len - 1] == '\n') {
|
||||||
|
data[len - 1] = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue