|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#include "sfllbuf.h" char * linebuf_prev (LINEBUF *buffer, DESCR *descr, const char *curline)
Fetches the previous line in the buffer, using the pointer that was returned by linebuf last(). Returns NULL if there are no more lines in the buffer, or a pointer for further calls. The line is stored in the supplied descriptor, and is truncated if the descriptor is too small.
{
ASSERT (buffer);
ASSERT (descr);
ASSERT (curline);
if (curline == buffer-> tail)
return (NULL); /* We're at the start */
else
{
/* We're pointing to the byte after the line's null byte */
buffer_dec (curline); /* Bump down to null */
ASSERT (*curline == '\0');
do
{
buffer_dec (curline); /* And now look for previous null */
if (*curline == '\0')
{
buffer_inc (curline); /* Bump up to start of string */
break;
}
}
until (curline == buffer-> tail);
get_line (buffer, descr, curline);
return ((char *) curline);
}
}
| | << | < | > | >> |
|