]> git.cameronkatri.com Git - mandoc.git/blobdiff - out.c
Make empty sections and parts (SH, SS, RS) only produce a warning if it
[mandoc.git] / out.c
diff --git a/out.c b/out.c
index 155957eae19b2d5e95a3410a0f3d2f35168bc4ed..eb303d5194f71f06b2dac153617c859a268ecb50 100644 (file)
--- a/out.c
+++ b/out.c
@@ -1,6 +1,7 @@
-/*     $Id: out.c,v 1.35 2011/01/11 14:12:01 kristaps Exp $ */
+/*     $Id: out.c,v 1.39 2011/03/17 08:49:34 kristaps Exp $ */
 /*
- * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -251,6 +252,49 @@ a2roffdeco(enum roffdeco *d, const char **word, size_t *sz)
                        break;
                }
                break;
+
+       case ('N'):
+
+               /*
+                * Sequence of characters:  backslash,  'N' (i = 0),
+                * starting delimiter (i = 1), character number (i = 2).
+                */
+
+               *word = wp + 2;
+               *sz = 0;
+
+               /*
+                * Cannot use a digit as a starting delimiter;
+                * but skip the digit anyway.
+                */
+
+               if (isdigit((int)wp[1]))
+                       return(2);
+
+               /*
+                * Any non-digit terminates the character number.
+                * That is, the terminating delimiter need not
+                * match the starting delimiter.
+                */
+
+               for (i = 2; isdigit((int)wp[i]); i++)
+                       (*sz)++;
+
+               /*
+                * This is only a numbered character
+                * if the character number has at least one digit.
+                */
+
+               if (*sz)
+                       *d = DECO_NUMBERED;
+
+               /*
+                * Skip the terminating delimiter, even if it does not
+                * match, and even if there is no character number.
+                */
+
+               return(++i);
+
        case ('h'):
                /* FALLTHROUGH */
        case ('v'):
@@ -387,7 +431,8 @@ tblcalc(struct rofftbl *tbl, const struct tbl_span *sp)
         */
 
        assert(NULL == tbl->cols);
-       tbl->cols = calloc(sp->tbl->cols, sizeof(struct roffcol));
+       tbl->cols = mandoc_calloc
+               ((size_t)sp->tbl->cols, sizeof(struct roffcol));
 
        hp = sp->head;
 
@@ -485,7 +530,7 @@ tblcalc_literal(struct rofftbl *tbl, struct roffcol *col,
        case (TBL_CELL_LONG):
                /* FALLTHROUGH */
        case (TBL_CELL_CENTRE):
-               bufsz = (*tbl->len)(2, tbl->arg);
+               bufsz = (*tbl->len)(1, tbl->arg);
                break;
        default:
                bufsz = (*tbl->len)(1, tbl->arg);