-.TH PD-ARGS 1 "July 29, 2012" OpenBSD
+.TH PD-ARGS 1 "December 23, 2014" OpenBSD
.SH NAME
PD-args \- unusual arguments to the PD macro
.SH DESCRIPTION
.PD 2p
.PP
argument(2p)
-.PD 1c
+.PD 1cx
.PP
-argument(1c)
+argument(1cx)
.PD xxx
.PP
argument(xxx)
argument(2p)
- argument(1c)
+ argument(1cx)
argument(xxx)
-OpenBSD July 29, 2012 PD-ARGS(1)
+OpenBSD December 23, 2014 PD-ARGS(1)
-.TH HORIZ 1 "November 20, 2014" OpenBSD
+.TH HORIZ 1 "December 23, 2014" OpenBSD
.SH NAME
horiz \- horizontal distances
.SH DESCRIPTION
5m
.in 79n
79n
+.in 1.5ix
+1.5ix
.PP
final text
10n
5m
79n
+ 1.5ix
final text
-OpenBSD November 20, 2014 HORIZ(1)
+OpenBSD December 23, 2014 HORIZ(1)
-.TH SP-BADARGS-MAN 1 "December 4, 2014" OpenBSD
+.TH SP-BADARGS-MAN 1 "December 23, 2014" OpenBSD
.SH NAME
sp-badargs-man \- bad arguments to .sp macros in man(7)
.SH DESCRIPTION
.sp 3v 2i
no scaling unit specified:
.sp 1
+trailing garbage:
+.sp 2vx
+garbage only:
+.sp xxx
end of test document
no scaling unit specified:
+ trailing garbage:
+
+
+ garbage only:
+
end of test document
-OpenBSD December 4, 2014 SP-BADARGS-MAN(1)
+OpenBSD December 23, 2014 SP-BADARGS-MAN(1)
-.Dd December 4, 2014
+.Dd December 23, 2014
.Dt SP-BADARGS-MDOC 1
.Os OpenBSD
.Sh NAME
.sp 3v 2i
no scaling unit specified:
.sp 1
+trailing garbage:
+.sp 2vx
+garbage only:
+.sp xxx
end of test document
no scaling unit specified:
+ trailing garbage:
+
+
+ garbage only:
+
end of test document
-OpenBSD December 4, 2014 OpenBSD
+OpenBSD December 23, 2014 OpenBSD
-/* $OpenBSD: man_html.c,v 1.60 2014/12/04 02:05:16 schwarze Exp $ */
+/* $OpenBSD: man_html.c,v 1.61 2014/12/23 09:31:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
if (MAN_sp == n->tok) {
if (NULL != (n = n->child))
if ( ! a2roffsu(n->string, &su, SCALE_VS))
- SCALE_VS_INIT(&su, atoi(n->string));
+ su.scale = 1.0;
} else
su.scale = 0.0;
-/* $OpenBSD: man_term.c,v 1.114 2014/12/23 08:15:37 schwarze Exp $ */
+/* $OpenBSD: man_term.c,v 1.115 2014/12/23 09:31:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
};
static int a2width(const struct termp *, const char *);
-static size_t a2height(const struct termp *, const char *);
static void print_man_nodelist(DECL_ARGS);
static void print_man_node(DECL_ARGS);
}
}
-
-static size_t
-a2height(const struct termp *p, const char *cp)
-{
- struct roffsu su;
-
- if ( ! a2roffsu(cp, &su, SCALE_VS))
- SCALE_VS_INIT(&su, atoi(cp));
-
- return(term_vspan(p, &su));
-}
-
static int
a2width(const struct termp *p, const char *cp)
{
static int
pre_sp(DECL_ARGS)
{
+ struct roffsu su;
char *s;
size_t i, len;
int neg;
neg = 1;
s++;
}
- len = a2height(p, s);
+ if ( ! a2roffsu(s, &su, SCALE_VS))
+ su.scale = 1.0;
+ len = term_vspan(p, &su);
break;
}
-/* $OpenBSD: mdoc_html.c,v 1.91 2014/12/02 10:07:17 schwarze Exp $ */
+/* $OpenBSD: mdoc_html.c,v 1.92 2014/12/23 09:31:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
a2width(const char *p, struct roffsu *su)
{
- if ( ! a2roffsu(p, su, SCALE_MAX)) {
+ if (a2roffsu(p, su, SCALE_MAX) < 2) {
su->unit = SCALE_EN;
su->scale = html_strlen(p);
}
if (MDOC_sp == n->tok) {
if (NULL != (n = n->child))
if ( ! a2roffsu(n->string, &su, SCALE_VS))
- SCALE_VS_INIT(&su, atoi(n->string));
+ su.scale = 1.0;
} else
su.scale = 0.0;
-/* $OpenBSD: mdoc_man.c,v 1.75 2014/11/30 05:28:00 schwarze Exp $ */
+/* $OpenBSD: mdoc_man.c,v 1.76 2014/12/23 09:31:17 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
sz = 6;
else if (keywords && !strcmp(v, "indent-two"))
sz = 12;
- else if (a2roffsu(v, &su, SCALE_MAX)) {
+ else if (a2roffsu(v, &su, SCALE_EN) < 2) {
if (SCALE_EN == su.unit)
sz = su.scale;
else {
/* Convert v into a number (of characters). */
if (NULL == v)
sz = defsz;
- else if (a2roffsu(v, &su, SCALE_MAX)) {
+ else if (a2roffsu(v, &su, SCALE_MAX) < 2) {
if (SCALE_EN == su.unit)
sz = su.scale;
else {
-/* $OpenBSD: mdoc_term.c,v 1.198 2014/12/02 10:07:17 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.199 2014/12/23 09:31:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
};
static size_t a2width(const struct termp *, const char *);
-static size_t a2height(const struct termp *, const char *);
static void print_bvspace(struct termp *,
const struct mdoc_node *,
free(volume);
}
-static size_t
-a2height(const struct termp *p, const char *v)
-{
- struct roffsu su;
-
-
- assert(v);
- if ( ! a2roffsu(v, &su, SCALE_VS))
- SCALE_VS_INIT(&su, atoi(v));
-
- return(term_vspan(p, &su));
-}
-
static size_t
a2width(const struct termp *p, const char *v)
{
struct roffsu su;
- assert(v);
- if ( ! a2roffsu(v, &su, SCALE_MAX)) {
+ if (a2roffsu(v, &su, SCALE_MAX) < 2) {
SCALE_HS_INIT(&su, term_strlen(p, v));
su.scale /= term_strlen(p, "0");
}
static int
termp_sp_pre(DECL_ARGS)
{
+ struct roffsu su;
size_t i, len;
switch (n->tok) {
case MDOC_sp:
- len = n->child ? a2height(p, n->child->string) : 1;
+ if (n->child) {
+ if ( ! a2roffsu(n->child->string, &su, SCALE_VS))
+ su.scale = 1.0;
+ len = term_vspan(p, &su);
+ } else
+ len = 1;
break;
case MDOC_br:
len = 0;
-/* $OpenBSD: out.c,v 1.27 2014/12/23 03:27:36 schwarze Exp $ */
+/* $OpenBSD: out.c,v 1.28 2014/12/23 09:31:17 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2014 Ingo Schwarze <schwarze@openbsd.org>
* Parse the *src string and store a scaling unit into *dst.
* If the string doesn't specify the unit, use the default.
* If no default is specified, fail.
- * Return 1 on success and 0 on failure.
+ * Return 2 on complete success, 1 when a conversion was done,
+ * but there was trailing garbage, and 0 on total failure.
*/
int
a2roffsu(const char *src, struct roffsu *dst, enum roffscale def)
{
char *endptr;
- double scale;
- enum roffscale unit;
- scale = strtod(src, &endptr);
- if (endptr == src || (endptr[0] != '\0' && endptr[1] != '\0'))
+ dst->unit = def == SCALE_MAX ? SCALE_BU : def;
+ dst->scale = strtod(src, &endptr);
+ if (endptr == src)
return(0);
- switch (*endptr) {
+ switch (*endptr++) {
case 'c':
- unit = SCALE_CM;
+ dst->unit = SCALE_CM;
break;
case 'i':
- unit = SCALE_IN;
+ dst->unit = SCALE_IN;
+ break;
+ case 'f':
+ dst->unit = SCALE_FS;
+ break;
+ case 'M':
+ dst->unit = SCALE_MM;
+ break;
+ case 'm':
+ dst->unit = SCALE_EM;
+ break;
+ case 'n':
+ dst->unit = SCALE_EN;
break;
case 'P':
- unit = SCALE_PC;
+ dst->unit = SCALE_PC;
break;
case 'p':
- unit = SCALE_PT;
+ dst->unit = SCALE_PT;
break;
- case 'f':
- unit = SCALE_FS;
+ case 'u':
+ dst->unit = SCALE_BU;
break;
case 'v':
- unit = SCALE_VS;
- break;
- case 'm':
- unit = SCALE_EM;
+ dst->unit = SCALE_VS;
break;
case '\0':
+ endptr--;
+ /* FALLTHROUGH */
+ default:
if (SCALE_MAX == def)
return(0);
- unit = def;
+ dst->unit = def;
break;
- case 'u':
- unit = SCALE_BU;
- break;
- case 'M':
- unit = SCALE_MM;
- break;
- case 'n':
- unit = SCALE_EN;
- break;
- default:
- return(0);
}
/* FIXME: do this in the caller. */
- if (scale < 0.0)
- scale = 0.0;
- dst->scale = scale;
- dst->unit = unit;
- return(1);
+ if (dst->scale < 0.0)
+ dst->scale = 0.0;
+ return(*endptr == '\0' ? 2 : 1);
}
/*