-/* $OpenBSD: compile.c,v 1.45 2017/12/12 12:52:01 martijn Exp $ */
+/* $OpenBSD: compile.c,v 1.46 2017/12/13 16:06:34 millert Exp $ */
/*-
* Copyright (c) 1992 Diomidis Spinellis.
{
static char *lbuf;
static size_t bufsize;
- int asize, ref, size;
+ size_t asize, ref, size;
char c, *text, *op, *sp;
int sawesc = 0;
static char *
compile_text(void)
{
- int asize, esc_nl, size;
+ size_t asize, size, bufsize;
char *lbuf, *text, *p, *op, *s;
- size_t bufsize;
+ int esc_nl;
lbuf = text = NULL;
asize = size = 0;
-/* $OpenBSD: defs.h,v 1.8 2017/01/20 10:26:16 krw Exp $ */
+/* $OpenBSD: defs.h,v 1.9 2017/12/13 16:06:34 millert Exp $ */
/*-
* Copyright (c) 1992 Diomidis Spinellis.
* Copyright (c) 1992, 1993
char *wfile; /* NULL if no wfile */
int wfd; /* Cached file descriptor */
regex_t *re; /* Regular expression */
- int maxbref; /* Largest backreference. */
+ u_int maxbref; /* Largest backreference. */
u_long linenum; /* Line number. */
char *new; /* Replacement text */
};
-/* $OpenBSD: main.c,v 1.35 2017/08/01 18:05:53 martijn Exp $ */
+/* $OpenBSD: main.c,v 1.36 2017/12/13 16:06:34 millert Exp $ */
/*-
* Copyright (c) 1992 Diomidis Spinellis.
state = ST_FILE;
goto again;
case CU_STRING:
- if ((snprintf(string_ident,
- sizeof(string_ident), "\"%s\"", script->s)) >=
- sizeof(string_ident))
+ len = snprintf(string_ident, sizeof(string_ident),
+ "\"%s\"", script->s);
+ if (len >= sizeof(string_ident))
strlcpy(string_ident +
sizeof(string_ident) - 6, " ...\"", 5);
fname = string_ident;
-/* $OpenBSD: process.c,v 1.32 2017/02/22 14:09:09 tom Exp $ */
+/* $OpenBSD: process.c,v 1.33 2017/12/13 16:06:34 millert Exp $ */
/*-
* Copyright (c) 1992 Diomidis Spinellis.
static int substitute(struct s_command *);
struct s_appends *appends; /* Array of pointers to strings to append. */
-static int appendx; /* Index into appends array. */
+static size_t appendx; /* Index into appends array. */
size_t appendnum; /* Size of appends array. */
static int lastaddr; /* Set by applies if last address of a range. */
DEFFILEMODE)) == -1)
error(FATAL, "%s: %s",
cp->t, strerror(errno));
- if (write(cp->u.fd, ps, psl) != psl ||
+ if ((size_t)write(cp->u.fd, ps, psl) != psl ||
write(cp->u.fd, "\n", 1) != 1)
error(FATAL, "%s: %s",
cp->t, strerror(errno));
regex_t *re;
regoff_t slen;
int n, lastempty;
- size_t le = 0;
+ regoff_t le = 0;
char *s;
s = ps;
if (cp->u.s->wfd == -1 && (cp->u.s->wfd = open(cp->u.s->wfile,
O_WRONLY|O_APPEND|O_CREAT|O_TRUNC, DEFFILEMODE)) == -1)
error(FATAL, "%s: %s", cp->u.s->wfile, strerror(errno));
- if (write(cp->u.s->wfd, ps, psl) != psl ||
+ if ((size_t)write(cp->u.s->wfd, ps, psl) != psl ||
write(cp->u.s->wfd, "\n", 1) != 1)
error(FATAL, "%s: %s", cp->u.s->wfile, strerror(errno));
}
flush_appends(void)
{
FILE *f;
- int count, i;
+ size_t count, idx;
char buf[8 * 1024];
- for (i = 0; i < appendx; i++)
- switch (appends[i].type) {
+ for (idx = 0; idx < appendx; idx++)
+ switch (appends[idx].type) {
case AP_STRING:
- fwrite(appends[i].s, sizeof(char), appends[i].len,
+ fwrite(appends[idx].s, sizeof(char), appends[idx].len,
outfile);
break;
case AP_FILE:
* would be truly bizarre, but possible. It's probably
* not that big a performance win, anyhow.
*/
- if ((f = fopen(appends[i].s, "r")) == NULL)
+ if ((f = fopen(appends[idx].s, "r")) == NULL)
break;
while ((count = fread(buf, sizeof(char), sizeof(buf), f)))
(void)fwrite(buf, sizeof(char), count, outfile);