version 1.244, 2014/12/18 17:43:41 |
version 1.249, 2015/01/14 22:58:16 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010, 2011, 2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
|
#include <limits.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
Line 650 roff_res(struct roff *r, struct buf *buf, int ln, int |
|
Line 651 roff_res(struct roff *r, struct buf *buf, int ln, int |
|
r->parse, ln, (int)(stesc - buf->buf), |
r->parse, ln, (int)(stesc - buf->buf), |
"%.*s", (int)naml, stnam); |
"%.*s", (int)naml, stnam); |
res = ""; |
res = ""; |
|
} else if (buf->sz + strlen(res) > SHRT_MAX) { |
|
mandoc_msg(MANDOCERR_ROFFLOOP, r->parse, |
|
ln, (int)(stesc - buf->buf), NULL); |
|
return(ROFF_IGN); |
} |
} |
|
|
/* Replace the escape sequence by the string. */ |
/* Replace the escape sequence by the string. */ |
Line 1158 roff_cond_sub(ROFF_ARGS) |
|
Line 1163 roff_cond_sub(ROFF_ARGS) |
|
*ep = '&'; |
*ep = '&'; |
roff_ccond(r, ln, ep - buf->buf - 1); |
roff_ccond(r, ln, ep - buf->buf - 1); |
} |
} |
++ep; |
if (*ep != '\0') |
|
++ep; |
} |
} |
return(rr ? ROFF_CONT : ROFF_IGN); |
return(rr ? ROFF_CONT : ROFF_IGN); |
} |
} |
Line 1178 roff_cond_text(ROFF_ARGS) |
|
Line 1184 roff_cond_text(ROFF_ARGS) |
|
*ep = '&'; |
*ep = '&'; |
roff_ccond(r, ln, ep - buf->buf - 1); |
roff_ccond(r, ln, ep - buf->buf - 1); |
} |
} |
++ep; |
if (*ep != '\0') |
|
++ep; |
} |
} |
return(rr ? ROFF_CONT : ROFF_IGN); |
return(rr ? ROFF_CONT : ROFF_IGN); |
} |
} |
Line 2096 roff_tr(ROFF_ARGS) |
|
Line 2103 roff_tr(ROFF_ARGS) |
|
static enum rofferr |
static enum rofferr |
roff_so(ROFF_ARGS) |
roff_so(ROFF_ARGS) |
{ |
{ |
char *name; |
char *name, *cp; |
|
|
name = buf->buf + pos; |
name = buf->buf + pos; |
mandoc_vmsg(MANDOCERR_SO, r->parse, ln, ppos, "so %s", name); |
mandoc_vmsg(MANDOCERR_SO, r->parse, ln, ppos, "so %s", name); |
Line 2111 roff_so(ROFF_ARGS) |
|
Line 2118 roff_so(ROFF_ARGS) |
|
if (*name == '/' || strstr(name, "../") || strstr(name, "/..")) { |
if (*name == '/' || strstr(name, "../") || strstr(name, "/..")) { |
mandoc_vmsg(MANDOCERR_SO_PATH, r->parse, ln, ppos, |
mandoc_vmsg(MANDOCERR_SO_PATH, r->parse, ln, ppos, |
".so %s", name); |
".so %s", name); |
return(ROFF_ERR); |
buf->sz = mandoc_asprintf(&cp, |
|
".sp\nSee the file %s.\n.sp", name) + 1; |
|
free(buf->buf); |
|
buf->buf = cp; |
|
*offs = 0; |
|
return(ROFF_REPARSE); |
} |
} |
|
|
*offs = pos; |
*offs = pos; |
Line 2162 roff_userdef(ROFF_ARGS) |
|
Line 2174 roff_userdef(ROFF_ARGS) |
|
buf->buf = n1; |
buf->buf = n1; |
if (buf->sz == 0) |
if (buf->sz == 0) |
buf->sz = strlen(buf->buf) + 1; |
buf->sz = strlen(buf->buf) + 1; |
|
*offs = 0; |
|
|
return(buf->sz > 1 && buf->buf[buf->sz - 2] == '\n' ? |
return(buf->sz > 1 && buf->buf[buf->sz - 2] == '\n' ? |
ROFF_REPARSE : ROFF_APPEND); |
ROFF_REPARSE : ROFF_APPEND); |