]> git.cameronkatri.com Git - mandoc.git/blobdiff - read.c
simple implementation of the roff(7) .als (macro alias) request,
[mandoc.git] / read.c
diff --git a/read.c b/read.c
index 6bc08463fc4ede0ca002afb5ddea12992b7c3e24..f86d57003a9726b9f4bea2adf1b974f498d5084d 100644 (file)
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/*     $Id: read.c,v 1.167 2017/05/31 15:31:00 schwarze Exp $ */
+/*     $Id: read.c,v 1.176 2017/06/11 19:37:01 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -88,8 +88,16 @@ static       const char * const      mandocerrs[MANDOCERR_MAX] = {
 
        "generic style suggestion",
 
 
        "generic style suggestion",
 
+       "Mdocdate found",
+       "Mdocdate missing",
+       "legacy man(7) date format",
        "useless macro",
        "consider using OS macro",
        "useless macro",
        "consider using OS macro",
+       "errnos out of order",
+       "duplicate errno",
+       "description line ends with a full stop",
+       "no blank before trailing delimiter",
+       "function name without markup",
 
        "generic warning",
 
 
        "generic warning",
 
@@ -138,6 +146,7 @@ static      const char * const      mandocerrs[MANDOCERR_MAX] = {
        "fill mode already enabled, skipping",
        "fill mode already disabled, skipping",
        "line scope broken",
        "fill mode already enabled, skipping",
        "fill mode already disabled, skipping",
        "line scope broken",
+       "skipping blank line in line scope",
 
        /* related to missing macro arguments */
        "skipping empty request",
 
        /* related to missing macro arguments */
        "skipping empty request",
@@ -173,6 +182,7 @@ static      const char * const      mandocerrs[MANDOCERR_MAX] = {
        "unknown AT&T UNIX version",
        "comma in function argument",
        "parenthesis in function name",
        "unknown AT&T UNIX version",
        "comma in function argument",
        "parenthesis in function name",
+       "unknown library name",
        "invalid content in Rs block",
        "invalid Boolean argument",
        "unknown font, skipping request",
        "invalid content in Rs block",
        "invalid Boolean argument",
        "unknown font, skipping request",
@@ -225,6 +235,7 @@ static      const char * const      mandocerrs[MANDOCERR_MAX] = {
        "NOT IMPLEMENTED: Bd -file",
        "skipping display without arguments",
        "missing list type, using -item",
        "NOT IMPLEMENTED: Bd -file",
        "skipping display without arguments",
        "missing list type, using -item",
+       "argument is not numeric, using 1",
        "missing manual name, using \"\"",
        "uname(3) system call failed, using UNKNOWN",
        "unknown standard specifier",
        "missing manual name, using \"\"",
        "uname(3) system call failed, using UNKNOWN",
        "unknown standard specifier",
@@ -324,7 +335,6 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start)
        const char      *save_file;
        char            *cp;
        size_t           pos; /* byte number in the ln buffer */
        const char      *save_file;
        char            *cp;
        size_t           pos; /* byte number in the ln buffer */
-       size_t           j;  /* auxiliary byte number in the blk buffer */
        enum rofferr     rr;
        int              of;
        int              lnn; /* line number in the real file */
        enum rofferr     rr;
        int              of;
        int              lnn; /* line number in the real file */
@@ -406,79 +416,14 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start)
                                continue;
                        }
 
                                continue;
                        }
 
-                       /* Trailing backslash = a plain char. */
-
-                       if (blk.buf[i] != '\\' || i + 1 == blk.sz) {
-                               ln.buf[pos++] = blk.buf[i++];
-                               continue;
-                       }
-
-                       /*
-                        * Found escape and at least one other character.
-                        * When it's a newline character, skip it.
-                        * When there is a carriage return in between,
-                        * skip that one as well.
-                        */
-
-                       if ('\r' == blk.buf[i + 1] && i + 2 < blk.sz &&
-                           '\n' == blk.buf[i + 2])
-                               ++i;
-                       if ('\n' == blk.buf[i + 1]) {
-                               i += 2;
-                               ++lnn;
-                               continue;
-                       }
-
-                       if ('"' == blk.buf[i + 1] || '#' == blk.buf[i + 1]) {
-                               j = i;
-                               i += 2;
-                               /* Comment, skip to end of line */
-                               for (; i < blk.sz; ++i) {
-                                       if (blk.buf[i] != '\n')
-                                               continue;
-                                       if (blk.buf[i - 1] == ' ' ||
-                                           blk.buf[i - 1] == '\t')
-                                               mandoc_msg(
-                                                   MANDOCERR_SPACE_EOL,
-                                                   curp, curp->line,
-                                                   pos + i-1 - j, NULL);
-                                       ++i;
-                                       ++lnn;
-                                       break;
-                               }
-
-                               /* Backout trailing whitespaces */
-                               for (; pos > 0; --pos) {
-                                       if (ln.buf[pos - 1] != ' ')
-                                               break;
-                                       if (pos > 2 && ln.buf[pos - 2] == '\\')
-                                               break;
-                               }
-                               break;
-                       }
-
-                       /* Catch escaped bogus characters. */
-
-                       c = (unsigned char) blk.buf[i+1];
-
-                       if ( ! (isascii(c) &&
-                           (isgraph(c) || isblank(c)))) {
-                               mandoc_vmsg(MANDOCERR_CHAR_BAD, curp,
-                                   curp->line, pos, "0x%x", c);
-                               i += 2;
-                               ln.buf[pos++] = '?';
-                               continue;
-                       }
-
-                       /* Some other escape sequence, copy & cont. */
-
-                       ln.buf[pos++] = blk.buf[i++];
                        ln.buf[pos++] = blk.buf[i++];
                }
 
                        ln.buf[pos++] = blk.buf[i++];
                }
 
-               if (pos >= ln.sz)
+               if (pos + 1 >= ln.sz)
                        resize_buf(&ln, 256);
 
                        resize_buf(&ln, 256);
 
+               if (i == blk.sz || blk.buf[i] == '\0')
+                       ln.buf[pos++] = '\n';
                ln.buf[pos] = '\0';
 
                /*
                ln.buf[pos] = '\0';
 
                /*