blob: 1566e0ce8501f235570827d1f995b282ecaaa969 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* copied from rsync */
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6#include <sys/types.h>
7#include <stdarg.h>
8static int foo(const char *format, ...)
9{
10 va_list ap;
11 size_t len;
12 char buf[5];
13
14 va_start(ap, format);
15 len = vsnprintf(0, 0, format, ap);
16 va_end(ap);
17 if (len != 5) return(1);
18
19 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) return(1);
20
21 return(0);
22}
23int main(void) { return foo("hello"); }