Lines Matching refs:line
44 struct line *tmp = a; \
71 struct line struct
85 struct line **lines; argument
89 static struct line *prevline[2] = {nullptr, nullptr};
100 static struct line *spareline[2] = {nullptr, nullptr};
171 static struct line uni_blank;
259 extract_field (struct line *line, char *field, idx_t len) in extract_field() argument
261 if (line->nfields >= line->nfields_allocated) in extract_field()
262 line->fields = xpalloc (line->fields, &line->nfields_allocated, 1, in extract_field()
263 -1, sizeof *line->fields); in extract_field()
264 line->fields[line->nfields].beg = field; in extract_field()
265 line->fields[line->nfields].len = len; in extract_field()
266 ++(line->nfields); in extract_field()
272 xfields (struct line *line) in xfields() argument
274 char *ptr = line->buf.buffer; in xfields()
275 char const *lim = ptr + line->buf.length - 1; in xfields()
284 extract_field (line, ptr, sep - ptr); in xfields()
298 extract_field (line, ptr, sep - ptr); in xfields()
307 extract_field (line, ptr, lim - ptr); in xfields()
311 freeline (struct line *line) in freeline() argument
313 if (line == nullptr) in freeline()
315 free (line->fields); in freeline()
316 line->fields = nullptr; in freeline()
317 free (line->buf.buffer); in freeline()
318 line->buf.buffer = nullptr; in freeline()
327 keycmp (struct line const *line1, struct line const *line2, in keycmp()
395 check_order (const struct line *prev, in check_order()
396 const struct line *current, in check_order()
431 reset_line (struct line *line) in reset_line() argument
433 line->nfields = 0; in reset_line()
436 static struct line *
437 init_linep (struct line **linep) in init_linep()
439 struct line *line = xzalloc (sizeof *line); in init_linep() local
440 *linep = line; in init_linep()
441 return line; in init_linep()
448 get_line (FILE *fp, struct line **linep, int which) in get_line()
450 struct line *line = *linep; in get_line() local
452 if (line == prevline[which - 1]) in get_line()
454 SWAPLINES (line, spareline[which - 1]); in get_line()
455 *linep = line; in get_line()
458 if (line) in get_line()
459 reset_line (line); in get_line()
461 line = init_linep (linep); in get_line()
463 if (! readlinebuffer_delim (&line->buf, fp, eolchar)) in get_line()
467 freeline (line); in get_line()
472 xfields (line); in get_line()
475 check_order (prevline[which - 1], line, which); in get_line()
477 prevline[which - 1] = line; in get_line()
549 prfield (idx_t n, struct line const *line) in prfield() argument
551 if (n < line->nfields) in prfield()
553 idx_t len = line->fields[n].len; in prfield()
555 fwrite (line->fields[n].beg, 1, len, stdout); in prfield()
566 prfields (struct line const *line, idx_t join_field, idx_t autocount) in prfields() argument
569 idx_t nfields = autoformat ? autocount : line->nfields; in prfields()
575 prfield (i, line); in prfields()
580 prfield (i, line); in prfields()
587 prjoin (struct line const *line1, struct line const *line2) in prjoin()
592 struct line const *line; in prjoin() local
606 line = line2; in prjoin()
611 line = line1; in prjoin()
617 line = (o->file == 1 ? line1 : line2); in prjoin()
620 prfield (field, line); in prjoin()
632 line = line2; in prjoin()
637 line = line1; in prjoin()
642 prfield (field, line); in prjoin()
681 struct line const *hline1 = seq1.count ? seq1.lines[0] : &uni_blank; in join()
682 struct line const *hline2 = seq2.count ? seq2.lines[0] : &uni_blank; in join()
770 struct line *line = nullptr; in join() local
783 while (get_line (fp1, &line, 1)) in join()
786 prjoin (line, &uni_blank); in join()
798 while (get_line (fp2, &line, 2)) in join()
801 prjoin (&uni_blank, line); in join()
807 freeline (line); in join()
808 free (line); in join()