allow for negative length (meaning left of start) in expand
This commit is contained in:
@ -273,9 +273,18 @@ StreamBuffer StreamBuffer::expand(long start, long length) const
|
||||
if (start < 0)
|
||||
{
|
||||
start += len;
|
||||
if (start < 0) start = 0;
|
||||
}
|
||||
end = length >= 0 ? start+length : len;
|
||||
if (length < 0)
|
||||
{
|
||||
start += length;
|
||||
length = -length;
|
||||
}
|
||||
if (start < 0)
|
||||
{
|
||||
length += start;
|
||||
start = 0;
|
||||
}
|
||||
end = start+length;
|
||||
if (end > len) end = len;
|
||||
StreamBuffer result((end-start)*2);
|
||||
start += offs;
|
||||
|
@ -218,7 +218,10 @@ public:
|
||||
|
||||
// expand: create copy of StreamBuffer where all nonprintable characters
|
||||
// are replaced by <xx> with xx being the hex code of the characters
|
||||
StreamBuffer expand(long start=0, long length=-1) const;
|
||||
StreamBuffer expand(long start, long length) const;
|
||||
|
||||
StreamBuffer expand(long start=0) const
|
||||
{return expand(start, len);}
|
||||
|
||||
// dump: debug function, like expand but also show the 'hidden' memory
|
||||
// before and after the real data. Uses colours.
|
||||
|
Reference in New Issue
Block a user