Blame src/regression/printf-fmt-n.c
|
Szabolcs Nagy |
cfa23c |
// commit: 5cbd76c6b05b381f269e0e204e10690d69f1d6ea 2011-02-16
|
|
Szabolcs Nagy |
cfa23c |
// commit: bdc9ed15651b70e89f83c5a9f7d1ba349e624503 2011-02-20
|
|
Szabolcs Nagy |
cfa23c |
// printf %n fmt
|
|
Szabolcs Nagy |
cfa23c |
#include <stdint.h>
|
|
Szabolcs Nagy |
cfa23c |
#include <stdio.h>
|
|
Szabolcs Nagy |
cfa23c |
#include "test.h"
|
|
Szabolcs Nagy |
cfa23c |
|
|
Szabolcs Nagy |
cfa23c |
#define T(n,nfmt,fmt) do { \
|
|
Szabolcs Nagy |
cfa23c |
if ((ret = sprintf(buf, "%256d%d" nfmt "%d", 1, 2, &n, 3)) != 258) \
|
|
Szabolcs Nagy |
cfa23c |
t_error("expexted sprintf to write 258 chars, got %d\n", ret); \
|
|
Szabolcs Nagy |
cfa23c |
if (n != 257) \
|
|
Szabolcs Nagy |
cfa23c |
t_error("%%n format failed: wanted 257, got " fmt "\n", n); \
|
|
Szabolcs Nagy |
cfa23c |
} while(0)
|
|
Szabolcs Nagy |
cfa23c |
|
|
Szabolcs Nagy |
cfa23c |
int main(void)
|
|
Szabolcs Nagy |
cfa23c |
{
|
|
Szabolcs Nagy |
cfa23c |
char buf[1024];
|
|
Szabolcs Nagy |
cfa23c |
int ret;
|
|
Szabolcs Nagy |
cfa23c |
int i;
|
|
Szabolcs Nagy |
cfa23c |
long l;
|
|
Szabolcs Nagy |
cfa23c |
long long ll;
|
|
Szabolcs Nagy |
cfa23c |
short h;
|
|
Szabolcs Nagy |
cfa23c |
size_t z;
|
|
Szabolcs Nagy |
cfa23c |
uintmax_t j;
|
|
Szabolcs Nagy |
cfa23c |
|
|
Szabolcs Nagy |
cfa23c |
T(i, "%n", "%d");
|
|
Szabolcs Nagy |
cfa23c |
T(l, "%ln", "%ld");
|
|
Szabolcs Nagy |
cfa23c |
T(ll, "%lln", "%lld");
|
|
Szabolcs Nagy |
cfa23c |
T(h, "%hn", "%d");
|
|
Szabolcs Nagy |
cfa23c |
T(z, "%zn", "%zd");
|
|
Szabolcs Nagy |
cfa23c |
T(j, "%jn", "%jd");
|
|
Szabolcs Nagy |
cfa23c |
|
|
Szabolcs Nagy |
cfa23c |
return t_status;
|
|
Szabolcs Nagy |
cfa23c |
}
|