Blame


1 12042ad7 2021-01-21 op /*
2 12042ad7 2021-01-21 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
3 12042ad7 2021-01-21 op *
4 12042ad7 2021-01-21 op * Permission to use, copy, modify, and distribute this software for any
5 12042ad7 2021-01-21 op * purpose with or without fee is hereby granted, provided that the above
6 12042ad7 2021-01-21 op * copyright notice and this permission notice appear in all copies.
7 12042ad7 2021-01-21 op *
8 12042ad7 2021-01-21 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 12042ad7 2021-01-21 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 12042ad7 2021-01-21 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 12042ad7 2021-01-21 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 12042ad7 2021-01-21 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 12042ad7 2021-01-21 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 12042ad7 2021-01-21 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 12042ad7 2021-01-21 op */
16 12042ad7 2021-01-21 op
17 12042ad7 2021-01-21 op #include <stdarg.h>
18 12042ad7 2021-01-21 op #include <stdio.h>
19 12042ad7 2021-01-21 op #include <string.h>
20 12042ad7 2021-01-21 op
21 12042ad7 2021-01-21 op static int testfn(char **, const char*, ...);
22 12042ad7 2021-01-21 op
23 12042ad7 2021-01-21 op static int
24 12042ad7 2021-01-21 op testfn(char **ret, const char *fmt, ...)
25 12042ad7 2021-01-21 op {
26 12042ad7 2021-01-21 op va_list ap;
27 12042ad7 2021-01-21 op int irc;
28 12042ad7 2021-01-21 op
29 12042ad7 2021-01-21 op va_start(ap, fmt);
30 12042ad7 2021-01-21 op irc = vasprintf(ret, fmt, ap);
31 12042ad7 2021-01-21 op va_end(ap);
32 12042ad7 2021-01-21 op
33 12042ad7 2021-01-21 op return irc;
34 12042ad7 2021-01-21 op }
35 12042ad7 2021-01-21 op
36 12042ad7 2021-01-21 op int
37 12042ad7 2021-01-21 op main(void)
38 12042ad7 2021-01-21 op {
39 12042ad7 2021-01-21 op char *ret;
40 12042ad7 2021-01-21 op
41 12042ad7 2021-01-21 op if (testfn(&ret, "%s.", "Text") != 5)
42 12042ad7 2021-01-21 op return 1;
43 12042ad7 2021-01-21 op if (strcmp(ret, "Text."))
44 12042ad7 2021-01-21 op return 2;
45 12042ad7 2021-01-21 op return 0;
46 12042ad7 2021-01-21 op }