Archive-Tar-Builder

 view release on metacpan or  search on metacpan

src/match_line_reader.c  view on Meta::CPAN

        return NULL;
    }

    lr->buff_length = 8192;
    lr->line_start = lr->line_end = lr->buff_end = lr->buff = NULL;

    return lr;
}

static void
lafe_line_reader_find_eol(struct lafe_line_reader *lr)
{

    lr->line_end += strcspn(lr->line_end, lr->nullSeparator ? "" : "\x0d\x0a");
    *lr->line_end = '\0'; /* Noop if line_end == buff_end */
}

int
lafe_line_reader_next(struct lafe_line_reader *lr, const char **next)
{
    size_t bytes_wanted, bytes_read, new_buff_size;
    char *line_start, *p;

    for (;;) {
        /* If there's a line in the buffer, return it immediately. */
        while (lr->line_end < lr->buff_end) {
            line_start     = lr->line_start;
            lr->line_start = ++lr->line_end;

            lafe_line_reader_find_eol(lr);

            if (lr->nullSeparator || line_start[0] != '\0') {
                *next = line_start;

                return 0;
            }
        }

        /* If we're at end-of-file, process the final data. */
        if (lr->f == NULL) {

src/match_line_reader.c  view on Meta::CPAN

            lr->line_end   = p + (lr->line_end - lr->buff);
            lr->line_start = lr->buff = p;
        }

        /* Get some more data into the buffer. */
        bytes_wanted  = lr->buff + lr->buff_length - lr->buff_end;
        bytes_read    = fread(lr->buff_end, 1, bytes_wanted, lr->f);
        lr->buff_end += bytes_read;
        *lr->buff_end = '\0'; /* Always terminate buffer */

        lafe_line_reader_find_eol(lr);

        if (ferror(lr->f)) {
            *next = NULL;

            return -1;
        }

        if (feof(lr->f)) {
            if (lr->f != stdin) {
                fclose(lr->f);



( run in 1.952 second using v1.01-cache-2.11-cpan-98e64b0badf )