Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix bug when trying to handle DW_OP_regN in MC_dwarf_resolve_location
[simgrid.git] / buildtools / Cmake / test_prog / prog_vsnprintf.c
1 /* Copyright (c) 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <stdio.h>
8 #include <stdarg.h>
9
10 int my_vsnprintf(char *buf, const char *tmpl, ...)
11 {
12   int i;
13   va_list args;
14   va_start(args, tmpl);
15   i = vsnprintf(buf, 2, tmpl, args);
16   va_end(args);
17   return i;
18 }
19
20 int main(void)
21 {
22   char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
23   char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
24   int i;
25   i = my_vsnprintf(bufs, "%s", "111");
26   if (strcmp(bufs, "1"))
27     exit(1);
28   if (i != 3)
29     exit(1);
30   i = my_vsnprintf(bufd, "%d", 111);
31   if (strcmp(bufd, "1"))
32     exit(1);
33   if (i != 3)
34     exit(1);
35   exit(0);
36 }