source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: downgrade .so failure from FATAL to ERROR
@ 2015-01-15  2:29 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2015-01-15  2:29 UTC (permalink / raw)
  To: source

Log Message:
-----------
downgrade .so failure from FATAL to ERROR

Modified Files:
--------------
    mdocml:
        mandoc.3
        mandoc.h
        read.c

Revision Data
-------------
Index: read.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/read.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -Lread.c -Lread.c -u -p -r1.109 -r1.110
--- read.c
+++ read.c
@@ -211,6 +211,7 @@ static	const char * const	mandocerrs[MAN
 	"unknown standard specifier",
 	"skipping request without numeric argument",
 	"NOT IMPLEMENTED: .so with absolute path or \"..\"",
+	".so request failed",
 	"skipping all arguments",
 	"skipping excess arguments",
 	"divide by zero",
@@ -218,7 +219,6 @@ static	const char * const	mandocerrs[MAN
 	"generic fatal error",
 
 	"input too large",
-	".so request failed",
 };
 
 static	const char * const	mandoclevels[MANDOCLEVEL_MAX] = {
@@ -306,10 +306,13 @@ mparse_buf_r(struct mparse *curp, struct
 {
 	const struct tbl_span	*span;
 	struct buf	 ln;
+	char		*cp;
 	size_t		 pos; /* byte number in the ln buffer */
 	enum rofferr	 rr;
 	int		 of;
 	int		 lnn; /* line number in the real file */
+	int		 fd;
+	pid_t		 save_child;
 	unsigned char	 c;
 
 	memset(&ln, 0, sizeof(ln));
@@ -518,13 +521,23 @@ rerun:
 			 */
 			if (curp->secondary)
 				curp->secondary->sz -= pos + 1;
-			mparse_readfd(curp, -1, ln.buf + of);
-			if (MANDOCLEVEL_FATAL <= curp->file_status) {
+			save_child = curp->child;
+			if (mparse_open(curp, &fd, ln.buf + of) ==
+			    MANDOCLEVEL_OK)
+				mparse_readfd(curp, fd, ln.buf + of);
+			else {
 				mandoc_vmsg(MANDOCERR_SO_FAIL,
 				    curp, curp->line, pos,
 				    ".so %s", ln.buf + of);
-				break;
+				ln.sz = mandoc_asprintf(&cp,
+				    ".sp\nSee the file %s.\n.sp",
+				    ln.buf + of);
+				free(ln.buf);
+				ln.buf = cp;
+				of = 0;
+				mparse_buf_r(curp, ln, of, 0);
 			}
+			curp->child = save_child;
 			pos = 0;
 			continue;
 		default:
@@ -750,8 +763,6 @@ mparse_readmem(struct mparse *curp, void
 }
 
 /*
- * If a file descriptor is given, use it and assume it points
- * to the named file.  Otherwise, open the named file.
  * Read the whole file into memory and call the parsers.
  * Called recursively when an .so request is encountered.
  */
@@ -761,13 +772,6 @@ mparse_readfd(struct mparse *curp, int f
 	struct buf	 blk;
 	int		 with_mmap;
 	int		 save_filenc;
-	pid_t		 save_child;
-
-	save_child = curp->child;
-	if (fd != -1)
-		curp->child = 0;
-	else if (mparse_open(curp, &fd, file) != MANDOCLEVEL_OK)
-		goto out;
 
 	if (read_whole_file(curp, file, fd, &blk, &with_mmap)) {
 		save_filenc = curp->filenc;
@@ -787,8 +791,6 @@ mparse_readfd(struct mparse *curp, int f
 		perror(file);
 
 	mparse_wait(curp);
-out:
-	curp->child = save_child;
 	return(curp->file_status);
 }
 
Index: mandoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.h,v
retrieving revision 1.180
retrieving revision 1.181
diff -Lmandoc.h -Lmandoc.h -u -p -r1.180 -r1.181
--- mandoc.h
+++ mandoc.h
@@ -167,6 +167,7 @@ enum	mandocerr {
 	MANDOCERR_ST_BAD, /* unknown standard specifier: St standard */
 	MANDOCERR_IT_NONUM, /* skipping request without numeric argument */
 	MANDOCERR_SO_PATH, /* NOT IMPLEMENTED: .so with absolute path or ".." */
+	MANDOCERR_SO_FAIL, /* .so request failed */
 	MANDOCERR_ARG_SKIP, /* skipping all arguments: macro args */
 	MANDOCERR_ARG_EXCESS, /* skipping excess arguments: macro ... args */
 	MANDOCERR_DIVZERO, /* divide by zero */
@@ -174,7 +175,6 @@ enum	mandocerr {
 	MANDOCERR_FATAL, /* ===== start of fatal errors ===== */
 
 	MANDOCERR_TOOLARGE, /* input too large */
-	MANDOCERR_SO_FAIL, /* .so request failed */
 
 	MANDOCERR_MAX
 };
Index: mandoc.3
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.3,v
retrieving revision 1.29
retrieving revision 1.30
diff -Lmandoc.3 -Lmandoc.3 -u -p -r1.29 -r1.30
--- mandoc.3
+++ mandoc.3
@@ -176,7 +176,9 @@ initiate a parsing sequence with
 and
 .Fn mparse_alloc ;
 .It
-parse files or file descriptors with
+parse files with
+.Fn mparse_open
+and
 .Fn mparse_readfd ;
 .It
 retrieve a parsed syntax tree, if the parse was successful, with
@@ -413,17 +415,12 @@ Declared in
 implemented in
 .Pa read.c .
 .It Fn mparse_readfd
-Parse a file or file descriptor.
-If
-.Va fd
-is -1, open
-.Va fname
-with
+Parse a file descriptor opened with
+.Xr open 2
+or
 .Fn mparse_open .
-Otherwise,
-.Va fname
-is assumed to be the name associated with
-.Va fd .
+Pass the associated filename in
+.Va fname .
 Calls
 .Fn mparse_wait
 before returning.
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-01-15  2:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-15  2:29 mdocml: downgrade .so failure from FATAL to ERROR schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).