Lines Matching refs:curp

261 choose_parser(struct mparse *curp)
272 if ((format = roff_getformat(curp->roff)) == 0) {
273 cp = curp->primary->buf;
274 ep = cp + curp->primary->sz;
294 if (curp->man == NULL) {
295 curp->man = roff_man_alloc(curp->roff, curp, curp->defos,
296 curp->options & MPARSE_QUICK ? 1 : 0);
297 curp->man->macroset = MACROSET_MAN;
298 curp->man->first->tok = TOKEN_NONE;
303 curp->man->macroset = MACROSET_MDOC;
304 curp->man->first->tok = TOKEN_NONE;
307 curp->man->macroset = MACROSET_MAN;
308 curp->man->first->tok = TOKEN_NONE;
320 mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start)
335 lnn = curp->line;
343 curp->line = lnn;
344 curp->reparse_count = 0;
347 curp->filenc & MPARSE_UTF8 &&
348 curp->filenc & MPARSE_LATIN1)
349 curp->filenc = preconv_cue(&blk, i);
383 if ( ! (curp->filenc && preconv_encode(
384 &blk, &i, &ln, &pos, &curp->filenc))) {
385 mandoc_vmsg(MANDOCERR_CHAR_BAD, curp,
386 curp->line, pos, "0x%x", c);
401 curp, curp->line, pos, "0x%x", c);
458 mandoc_vmsg(MANDOCERR_CHAR_BAD, curp,
459 curp->line, pos, "0x%x", c);
493 if (curp->secondary) {
494 curp->secondary->buf = mandoc_realloc(
495 curp->secondary->buf,
496 curp->secondary->sz + pos + 2);
497 memcpy(curp->secondary->buf +
498 curp->secondary->sz,
500 curp->secondary->sz += pos;
501 curp->secondary->buf
502 [curp->secondary->sz] = '\n';
503 curp->secondary->sz++;
504 curp->secondary->buf
505 [curp->secondary->sz] = '\0';
508 rr = roff_parseln(curp->roff, curp->line, &ln, &of);
512 if (REPARSE_LIMIT >= ++curp->reparse_count)
513 mparse_buf_r(curp, ln, of, 0);
515 mandoc_msg(MANDOCERR_ROFFLOOP, curp,
516 curp->line, pos, NULL);
528 if ( ! (curp->options & MPARSE_SO) &&
530 curp->sodest = mandoc_strdup(ln.buf + of);
539 if (curp->secondary)
540 curp->secondary->sz -= pos + 1;
541 save_file = curp->file;
542 if ((fd = mparse_open(curp, ln.buf + of)) != -1) {
543 mparse_readfd(curp, fd, ln.buf + of);
545 curp->file = save_file;
547 curp->file = save_file;
549 curp, curp->line, pos,
557 mparse_buf_r(curp, ln, of, 0);
572 if (curp->man == NULL ||
573 curp->man->macroset == MACROSET_NONE)
574 choose_parser(curp);
586 while ((span = roff_span(curp->roff)) != NULL)
587 roff_addtbl(curp->man, span);
589 roff_addeqn(curp->man, roff_eqn(curp->roff));
590 else if ((curp->man->macroset == MACROSET_MDOC ?
591 mdoc_parseln(curp->man, curp->line, ln.buf, of) :
592 man_parseln(curp->man, curp->line, ln.buf, of)) == 2)
609 read_whole_file(struct mparse *curp, const char *file, int fd,
629 if (curp->gzip == 0 && S_ISREG(st.st_mode)) {
631 mandoc_msg(MANDOCERR_TOOLARGE, curp, 0, 0, NULL);
642 if (curp->gzip) {
660 mandoc_msg(MANDOCERR_TOOLARGE, curp,
666 ssz = curp->gzip ?
684 mparse_end(struct mparse *curp)
687 if (curp->man == NULL && curp->sodest == NULL)
688 curp->man = roff_man_alloc(curp->roff, curp, curp->defos,
689 curp->options & MPARSE_QUICK ? 1 : 0);
690 if (curp->man->macroset == MACROSET_NONE)
691 curp->man->macroset = MACROSET_MAN;
692 if (curp->man->macroset == MACROSET_MDOC)
693 mdoc_endparse(curp->man);
695 man_endparse(curp->man);
696 roff_endparse(curp->roff);
700 mparse_parse_buffer(struct mparse *curp, struct buf blk, const char *file)
708 mandoc_msg(MANDOCERR_ROFFLOOP, curp, curp->line, 0, NULL);
713 svfile = curp->file;
714 curp->file = file;
715 svprimary = curp->primary;
716 curp->primary = &blk;
717 curp->line = 1;
721 if (curp->filenc & MPARSE_UTF8 && blk.sz > 2 &&
726 curp->filenc &= ~MPARSE_LATIN1;
730 mparse_buf_r(curp, blk, offset, 1);
733 mparse_end(curp);
735 curp->primary = svprimary;
736 curp->file = svfile;
740 mparse_readmem(struct mparse *curp, void *buf, size_t len,
748 mparse_parse_buffer(curp, blk, file);
749 return curp->file_status;
757 mparse_readfd(struct mparse *curp, int fd, const char *file)
763 if (read_whole_file(curp, file, fd, &blk, &with_mmap)) {
764 save_filenc = curp->filenc;
765 curp->filenc = curp->options &
767 mparse_parse_buffer(curp, blk, file);
768 curp->filenc = save_filenc;
776 return curp->file_status;
780 mparse_open(struct mparse *curp, const char *file)
785 curp->file = file;
787 curp->gzip = (cp != NULL && ! strcmp(cp + 1, "gz"));
799 if ( ! curp->gzip) {
804 curp->gzip = 1;
811 mandoc_msg(MANDOCERR_FILE, curp, 0, 0, strerror(errno));
819 struct mparse *curp;
821 curp = mandoc_calloc(1, sizeof(struct mparse));
823 curp->options = options;
824 curp->wlevel = wlevel;
825 curp->mmsg = mmsg;
826 curp->defos = defos;
828 curp->roff = roff_alloc(curp, options);
829 curp->man = roff_man_alloc( curp->roff, curp, curp->defos,
830 curp->options & MPARSE_QUICK ? 1 : 0);
831 if (curp->options & MPARSE_MDOC) {
833 curp->man->macroset = MACROSET_MDOC;
834 } else if (curp->options & MPARSE_MAN) {
836 curp->man->macroset = MACROSET_MAN;
838 curp->man->first->tok = TOKEN_NONE;
839 return curp;
843 mparse_reset(struct mparse *curp)
846 roff_reset(curp->roff);
848 if (curp->man != NULL)
849 roff_man_reset(curp->man);
850 if (curp->secondary)
851 curp->secondary->sz = 0;
853 curp->file_status = MANDOCLEVEL_OK;
855 free(curp->sodest);
856 curp->sodest = NULL;
860 mparse_free(struct mparse *curp)
863 roff_man_free(curp->man);
864 if (curp->roff)
865 roff_free(curp->roff);
866 if (curp->secondary)
867 free(curp->secondary->buf);
869 free(curp->secondary);
870 free(curp->sodest);
871 free(curp);
875 mparse_result(struct mparse *curp, struct roff_man **man,
879 if (sodest && NULL != (*sodest = curp->sodest)) {
884 *man = curp->man;