Lines Matching defs:curp

98 choose_parser(struct mparse *curp)
109 if ((format = roff_getformat(curp->roff)) == 0) {
110 cp = curp->primary->buf;
111 ep = cp + curp->primary->sz;
132 curp->man->meta.macroset = MACROSET_MDOC;
133 if (curp->man->mdocmac == NULL)
134 curp->man->mdocmac = roffhash_alloc(MDOC_Dd, MDOC_MAX);
136 curp->man->meta.macroset = MACROSET_MAN;
137 if (curp->man->manmac == NULL)
138 curp->man->manmac = roffhash_alloc(MAN_TH, MAN_MAX);
140 curp->man->meta.first->tok = TOKEN_NONE;
151 mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start)
169 lnn = curp->line;
176 curp->line = lnn;
177 curp->reparse_count = 0;
180 curp->filenc & MPARSE_UTF8 &&
181 curp->filenc & MPARSE_LATIN1)
182 curp->filenc = preconv_cue(&blk, i);
217 if ( ! (curp->filenc && preconv_encode(
218 &blk, &i, &ln, &pos, &curp->filenc))) {
220 curp->line, pos, "0x%x", c);
235 curp->line, pos, "0x%x", c);
257 if (curp->secondary == NULL)
258 curp->secondary = firstln;
289 line_result = roff_parseln(curp->roff, curp->line,
313 if (curp->loop != NULL) {
314 if (loop == curp->loop)
317 curp->line, pos, NULL);
319 curp->loop = thisln;
325 if (curp->loop == NULL) {
327 curp->line, pos, NULL);
332 curp->line, pos, NULL);
333 curp->loop = loop = NULL;
337 loop = curp->loop;
339 curp->loop = loop = NULL;
353 if (curp->man->meta.macroset == MACROSET_NONE)
354 choose_parser(curp);
355 if ((curp->man->meta.macroset == MACROSET_MDOC ?
356 mdoc_parseln(curp->man, curp->line, ln.buf, of) :
357 man_parseln(curp->man, curp->line, ln.buf, of)
364 if (++curp->reparse_count > REPARSE_LIMIT) {
368 curp->line, pos, NULL);
371 result = mparse_buf_r(curp, ln, of, 0);
373 roff_userret(curp->roff);
382 if ( ! (curp->options & MPARSE_SO) &&
384 curp->man->meta.sodest =
388 if ((fd = mparse_open(curp, ln.buf + of)) != -1) {
389 mparse_readfd(curp, fd, ln.buf + of);
393 curp->line, of, ".so %s: %s",
401 mparse_buf_r(curp, ln, of, 0);
430 curp->line, pos, NULL);
431 curp->loop = NULL;
434 if (firstln != curp->secondary)
440 read_whole_file(struct mparse *curp, int fd, struct buf *fb, int *with_mmap)
460 if (curp->gzip == 0 && S_ISREG(st.st_mode)) {
472 if (curp->gzip) {
512 ssz = curp->gzip ?
521 if (curp->gzip)
524 curp->gzip && gzerrnum != Z_ERRNO ?
531 if (curp->gzip && (gzerrnum = gzclose(gz)) != Z_OK)
543 mparse_end(struct mparse *curp)
545 if (curp->man->meta.macroset == MACROSET_NONE)
546 curp->man->meta.macroset = MACROSET_MAN;
547 if (curp->man->meta.macroset == MACROSET_MDOC)
548 mdoc_endparse(curp->man);
550 man_endparse(curp->man);
551 roff_endparse(curp->roff);
559 mparse_readfd(struct mparse *curp, int fd, const char *filename)
571 mandoc_msg(MANDOCERR_ROFFLOOP, curp->line, 0, NULL);
576 curp->man->filesec = cp[1];
578 curp->man->filesec = '\0';
580 if (read_whole_file(curp, fd, &blk, &with_mmap) == -1)
587 save_primary = curp->primary;
588 save_filenc = curp->filenc;
589 save_lineno = curp->line;
592 curp->primary = &blk;
593 curp->filenc = curp->options & (MPARSE_UTF8 | MPARSE_LATIN1);
594 curp->line = 1;
598 if (curp->filenc & MPARSE_UTF8 && blk.sz > 2 &&
603 curp->filenc &= ~MPARSE_LATIN1;
608 mparse_buf_r(curp, blk, offset, 1);
610 mparse_end(curp);
621 curp->primary = save_primary;
622 curp->filenc = save_filenc;
623 curp->line = save_lineno;
629 mparse_open(struct mparse *curp, const char *file)
635 curp->gzip = (cp != NULL && ! strcmp(cp + 1, "gz"));
647 if ( ! curp->gzip) {
654 curp->gzip = 1;
667 struct mparse *curp;
669 curp = mandoc_calloc(1, sizeof(struct mparse));
671 curp->options = options;
672 curp->os_s = os_s;
674 curp->roff = roff_alloc(options);
675 curp->man = roff_man_alloc(curp->roff, curp->os_s,
676 curp->options & MPARSE_QUICK ? 1 : 0);
677 if (curp->options & MPARSE_MDOC) {
678 curp->man->meta.macroset = MACROSET_MDOC;
679 if (curp->man->mdocmac == NULL)
680 curp->man->mdocmac = roffhash_alloc(MDOC_Dd, MDOC_MAX);
681 } else if (curp->options & MPARSE_MAN) {
682 curp->man->meta.macroset = MACROSET_MAN;
683 if (curp->man->manmac == NULL)
684 curp->man->manmac = roffhash_alloc(MAN_TH, MAN_MAX);
686 curp->man->meta.first->tok = TOKEN_NONE;
687 curp->man->meta.os_e = os_e;
689 return curp;
693 mparse_reset(struct mparse *curp)
696 roff_reset(curp->roff);
697 roff_man_reset(curp->man);
698 free_buf_list(curp->secondary);
699 curp->secondary = NULL;
700 curp->gzip = 0;
705 mparse_free(struct mparse *curp)
708 roffhash_free(curp->man->mdocmac);
709 roffhash_free(curp->man->manmac);
710 roff_man_free(curp->man);
711 roff_free(curp->roff);
712 free_buf_list(curp->secondary);
713 free(curp);
717 mparse_result(struct mparse *curp)
719 roff_state_reset(curp->man);
720 if (curp->options & MPARSE_VALIDATE) {
721 if (curp->man->meta.macroset == MACROSET_MDOC)
722 mdoc_validate(curp->man);
724 man_validate(curp->man);
725 tag_postprocess(curp->man, curp->man->meta.first);
727 return &curp->man->meta;