[BACK]Return to test-vasprintf.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Annotation of mandoc/test-vasprintf.c, Revision 1.1

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

CVSweb