aboutsummaryrefslogtreecommitdiff
path: root/src/base/fmt/write.c
blob: 339b3911a09ab7c5467e4fdb5db1d1150405d7da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "internal.h"

int
fmt·write(fmt·State *io, char *fmt, ...)
{
    int n;
    va_list args;

    io->flag = io->width = io->prec = 0;

    va_copy(args, io->args);
    va_end(io->args);

    va_start(io->args, fmt);
    n = fmt·do(io, fmt);
    va_end(io->args);

    io->flag = io->width = io->prec = 0;
    va_copy(io->args, args);
    va_end(args);

    if(n >= 0)
        return 0;
    return n;
}