mirror of https://github.com/Icinga/icinga2.git
parent
02d1f1cc57
commit
1c213877a4
|
@ -129,40 +129,19 @@ StreamReadStatus Stream::ReadLine(String *line, StreamReadContext& context, bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
size_t first_newline;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < context.Size; i++) {
|
for (size_t i = 0; i < context.Size; i++) {
|
||||||
if (context.Buffer[i] == '\n') {
|
if (context.Buffer[i] == '\n') {
|
||||||
count++;
|
*line = String(context.Buffer, context.Buffer + i);
|
||||||
|
boost::algorithm::trim_right(*line);
|
||||||
|
|
||||||
if (count == 1)
|
context.DropData(i + 1u);
|
||||||
first_newline = i;
|
|
||||||
else if (count > 1)
|
context.MustRead = !context.Size;
|
||||||
break;
|
return StatusNewItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (count) {
|
context.MustRead = true;
|
||||||
case 0:
|
|
||||||
context.MustRead = true;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
context.MustRead = first_newline == (context.Size - 1u);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
context.MustRead = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count > 0) {
|
|
||||||
*line = String(context.Buffer, &(context.Buffer[first_newline]));
|
|
||||||
boost::algorithm::trim_right(*line);
|
|
||||||
|
|
||||||
context.DropData(first_newline + 1);
|
|
||||||
|
|
||||||
return StatusNewItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
return StatusNeedData;
|
return StatusNeedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue