version 1.397, 2023/10/21 17:10:18 |
version 1.400, 2023/10/24 20:53:12 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010-2015, 2017-2023 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
Line 367 const char *__roff_name[MAN_MAX + 1] = { |
|
Line 367 const char *__roff_name[MAN_MAX + 1] = { |
|
"PD", "AT", "in", |
"PD", "AT", "in", |
"SY", "YS", "OP", |
"SY", "YS", "OP", |
"EX", "EE", "UR", |
"EX", "EE", "UR", |
"UE", "MT", "ME", NULL |
"UE", "MT", "ME", "MR", |
|
NULL |
}; |
}; |
const char *const *roff_name = __roff_name; |
const char *const *roff_name = __roff_name; |
|
|
Line 1362 roff_expand(struct roff *r, struct buf *buf, int ln, i |
|
Line 1363 roff_expand(struct roff *r, struct buf *buf, int ln, i |
|
const char *res; /* the string to be pasted */ |
const char *res; /* the string to be pasted */ |
const char *src; /* source for copying */ |
const char *src; /* source for copying */ |
char *dst; /* destination for copying */ |
char *dst; /* destination for copying */ |
|
enum mandoc_esc subtype; /* return value from roff_escape */ |
int iesc; /* index of leading escape char */ |
int iesc; /* index of leading escape char */ |
int inam; /* index of the escape name */ |
int inam; /* index of the escape name */ |
int iarg; /* index beginning the argument */ |
int iarg; /* index beginning the argument */ |
Line 1551 roff_expand(struct roff *r, struct buf *buf, int ln, i |
|
Line 1553 roff_expand(struct roff *r, struct buf *buf, int ln, i |
|
res = ubuf; |
res = ubuf; |
break; |
break; |
case 'w': |
case 'w': |
(void)snprintf(ubuf, sizeof(ubuf), |
rsz = 0; |
"%d", (iendarg - iarg) * 24); |
subtype = ESCAPE_UNDEF; |
|
while (iarg < iendarg) { |
|
asz = subtype == ESCAPE_SKIPCHAR ? 0 : 1; |
|
if (buf->buf[iarg] != '\\') { |
|
rsz += asz; |
|
iarg++; |
|
continue; |
|
} |
|
switch ((subtype = roff_escape(buf->buf, 0, |
|
iarg, NULL, NULL, NULL, NULL, &iarg))) { |
|
case ESCAPE_SPECIAL: |
|
case ESCAPE_NUMBERED: |
|
case ESCAPE_UNICODE: |
|
case ESCAPE_OVERSTRIKE: |
|
case ESCAPE_UNDEF: |
|
break; |
|
case ESCAPE_DEVICE: |
|
asz *= 8; |
|
break; |
|
case ESCAPE_EXPAND: |
|
abort(); |
|
default: |
|
continue; |
|
} |
|
rsz += asz; |
|
} |
|
(void)snprintf(ubuf, sizeof(ubuf), "%d", rsz * 24); |
res = ubuf; |
res = ubuf; |
break; |
break; |
default: |
default: |
Line 1689 roff_getarg(struct roff *r, char **cpp, int ln, int *p |
|
Line 1717 roff_getarg(struct roff *r, char **cpp, int ln, int *p |
|
buf.buf = start; |
buf.buf = start; |
buf.sz = strlen(start) + 1; |
buf.sz = strlen(start) + 1; |
buf.next = NULL; |
buf.next = NULL; |
if (roff_expand(r, &buf, ln, 0, '\\') & ROFF_IGN) { |
if (roff_expand(r, &buf, ln, 0, '\\') == ROFF_IGN) { |
free(buf.buf); |
free(buf.buf); |
buf.buf = mandoc_strdup(""); |
buf.buf = mandoc_strdup(""); |
} |
} |