mirror of
https://github.com/sheumann/hush.git
synced 2025-01-04 22:34:37 +00:00
- fix bug #887, in bb_get_chomped_line_from_file(), the last char was removed
unconditionally, even if it was not a newline. This was apparently broken by r14254 - whitespace while at it.
This commit is contained in:
parent
6ba8bbe88a
commit
2d1a6e7c1f
@ -31,9 +31,11 @@ char *bb_get_chunk_from_file(FILE *file, int *end)
|
|||||||
linebuf = xrealloc(linebuf, linebufsz += 80);
|
linebuf = xrealloc(linebuf, linebufsz += 80);
|
||||||
}
|
}
|
||||||
linebuf[idx++] = (char) ch;
|
linebuf[idx++] = (char) ch;
|
||||||
if (!ch || (end && ch == '\n')) break;
|
if (!ch || (end && ch == '\n'))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (end) *end = idx;
|
if (end)
|
||||||
|
*end = idx;
|
||||||
if (linebuf) {
|
if (linebuf) {
|
||||||
if (ferror(file)) {
|
if (ferror(file)) {
|
||||||
free(linebuf);
|
free(linebuf);
|
||||||
@ -48,6 +50,7 @@ char *bb_get_chunk_from_file(FILE *file, int *end)
|
|||||||
char *bb_get_line_from_file(FILE * file)
|
char *bb_get_line_from_file(FILE * file)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
return bb_get_chunk_from_file(file, &i);
|
return bb_get_chunk_from_file(file, &i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +59,9 @@ char *bb_get_chomped_line_from_file(FILE *file)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *c = bb_get_chunk_from_file(file, &i);
|
char *c = bb_get_chunk_from_file(file, &i);
|
||||||
if(i) c[--i]=0;
|
|
||||||
|
if (i && c[--i] == '\n')
|
||||||
|
c[i] = 0;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user