Skip to content

Commit af628b8

Browse files
committed
upstream: add allocating variant of the safe utf8 printer; ok
dtucker as part of a larger diff OpenBSD-Commit-ID: 037e2965bd50eacc2ffb49889ecae41552744fa0
1 parent d8ac9af commit af628b8

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

utf8.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: utf8.c,v 1.9 2020/03/06 18:12:55 markus Exp $ */
1+
/* $OpenBSD: utf8.c,v 1.10 2020/04/03 02:25:21 djm Exp $ */
22
/*
33
* Copyright (c) 2016 Ingo Schwarze <[email protected]>
44
*
@@ -255,6 +255,20 @@ snmprintf(char *str, size_t sz, int *wp, const char *fmt, ...)
255255
return ret;
256256
}
257257

258+
int
259+
asmprintf(char **outp, size_t sz, int *wp, const char *fmt, ...)
260+
{
261+
va_list ap;
262+
int ret;
263+
264+
*outp = NULL;
265+
va_start(ap, fmt);
266+
ret = vasnmprintf(outp, sz, wp, fmt, ap);
267+
va_end(ap);
268+
269+
return ret;
270+
}
271+
258272
/*
259273
* To stay close to the standard interfaces, the following functions
260274
* return the number of non-NUL bytes written.

utf8.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: utf8.h,v 1.1 2016/05/25 23:48:45 schwarze Exp $ */
1+
/* $OpenBSD: utf8.h,v 1.2 2020/04/03 02:25:21 djm Exp $ */
22
/*
33
* Copyright (c) 2016 Ingo Schwarze <[email protected]>
44
*
@@ -22,4 +22,6 @@ int fmprintf(FILE *, const char *, ...)
2222
int vfmprintf(FILE *, const char *, va_list);
2323
int snmprintf(char *, size_t, int *, const char *, ...)
2424
__attribute__((format(printf, 4, 5)));
25+
int asmprintf(char **, size_t, int *, const char *, ...)
26+
__attribute__((format(printf, 4, 5)));
2527
void msetlocale(void);

0 commit comments

Comments
 (0)